Technical Archives - Monsieur Winner https://blog.monsieurwinner.com/category/technical/ MS D365FO || Monsieur D365FO Sun, 15 Sep 2024 07:46:00 +0000 en-US hourly 1 https://wordpress.org/?v=6.6.2 https://i0.wp.com/blog.monsieurwinner.com/wp-content/uploads/2022/09/cropped-Winner-.png?fit=32%2C32&ssl=1 Technical Archives - Monsieur Winner https://blog.monsieurwinner.com/category/technical/ 32 32 209261758 Copy database from D365FO On premises to Cloud hosted environment https://blog.monsieurwinner.com/2024/09/15/copy-sql-database-from-d365fo-on-prem-to-cloud-hosted-environment/ https://blog.monsieurwinner.com/2024/09/15/copy-sql-database-from-d365fo-on-prem-to-cloud-hosted-environment/#respond Sun, 15 Sep 2024 07:46:00 +0000 https://blog.monsieurwinner.com/?p=740 We can move database from On premises environment to a cloud hosted environment for testing purposes. This process is quite

The post Copy database from D365FO On premises to Cloud hosted environment appeared first on Monsieur Winner.

]]>
We can move database from On premises environment to a cloud hosted environment for testing purposes. This process is quite seamless as both environment are SQL severs. Hence, we backup from A and restore on B.

 

A. Take a back up of AXDB on the On-premises environment

B. Restore the database on the Cloud hosted environment(CHE).

C. Run some sql script against the CHE to update certain values.

D. Synchronize the CHE database.

 

I would skip the steps A and B and move straight to the scripts.

Step 1

USE AXDBonprem;
SELECT s.name
FROM sys.schemas s
WHERE s.principal_id = USER_ID('axdbadmin');

Step 2


ALTER AUTHORIZATION ON SCHEMA::db_owner TO dbo;
ALTER AUTHORIZATION ON SCHEMA::db_ddladmin TO dbo;
ALTER AUTHORIZATION ON SCHEMA::db_datareader TO dbo;
ALTER AUTHORIZATION ON SCHEMA::db_datawriter TO dbo;

step3

USE AXDBonprem;
declare
@userSQL varchar(1000)
set quoted_identifier off
declare userCursor CURSOR for
select 'DROP USER [' + name +']'
from sys.sysusers
where issqlrole = 0 and hasdbaccess = 1 and name != 'dbo' and name != 'NT AUTHORITY\NETWORK SERVICE'
OPEN userCursor
FETCH userCursor into @userSQL
WHILE @@Fetch_Status = 0
BEGIN
exec(@userSQL)
FETCH userCursor into @userSQL
END
CLOSE userCursor
DEALLOCATE userCursor

step4

–now recreate the users copying from the existing database:
use AXDB –******************* SET THE OLD TIER 1 DATABASE NAME****************************

go
IF object_id('tempdb..#UsersToCreate') is not null
DROP TABLE #UsersToCreate
go
select 'CREATE USER [' + name + '] FROM LOGIN [' + name + '] EXEC sp_addrolemember "db_owner", "' + name + '"' as sqlcommand
into #UsersToCreate
from sys.sysusers
where issqlrole = 0 and hasdbaccess = 1 and name != 'dbo' and name != 'NT AUTHORITY\NETWORK SERVICE'

step 5


go
use AXDBonprem --******************* SET THE NEWLY RESTORED DATABASE NAME****************************
go
declare
@userSQL varchar(1000)
set quoted_identifier off
declare userCursor CURSOR for
select sqlcommand from #UsersToCreate
OPEN userCursor
FETCH userCursor into @userSQL
WHILE @@Fetch_Status = 0
BEGIN
exec(@userSQL)
FETCH userCursor into @userSQL
END
CLOSE userCursor
DEALLOCATE userCursor

STEP 6
COPY ADMIN USER

use AXDBonprem
--Update the Admin user record, so that I can log in again
UPDATE USERINFO
SET SID = x.SID, NETWORKDOMAIN = x.NETWORKDOMAIN, NETWORKALIAS = x.NETWORKALIAS,
IDENTITYPROVIDER = x.IDENTITYPROVIDER
FROM AXDB..USERINFO x --******************* SET THE OLD TIER 1 DATABASE NAME****************************
WHERE x.ID = 'Admin' and USERINFO.ID = 'Admin'

STEP 7

Now, let’s rename the orginal AXDB to AXDB_old

USE master
GO
ALTER DATABASE AxDB
SET SINGLE_USER
WITH ROLLBACK IMMEDIATE
GO
ALTER DATABASE AxDB
Modify Name = AxDBold
GO
ALTER DATABASE AxDBold
SET MULTI_USER
GO

Step 8

Rename AXDBonprem to AXDB


USE master
GO
ALTER DATABASE AxDBonprem
SET SINGLE_USER
WITH ROLLBACK IMMEDIATE
GO
ALTER DATABASE AxDBonprem
Modify Name = AxDB
GO
ALTER DATABASE AxDB
SET MULTI_USER
GO

 

The post Copy database from D365FO On premises to Cloud hosted environment appeared first on Monsieur Winner.

]]>
https://blog.monsieurwinner.com/2024/09/15/copy-sql-database-from-d365fo-on-prem-to-cloud-hosted-environment/feed/ 0 740
Missing TFVC Option in Azure DevOps: Creating a New Project https://blog.monsieurwinner.com/2024/08/07/missing-tfvc-option-in-azure-devops-creating-a-new-project/ https://blog.monsieurwinner.com/2024/08/07/missing-tfvc-option-in-azure-devops-creating-a-new-project/#respond Wed, 07 Aug 2024 18:52:43 +0000 https://blog.monsieurwinner.com/?p=733 It’s August 2024, and I am trying to create a create a new Azure DevOps project for a new Dynamics

The post Missing TFVC Option in Azure DevOps: Creating a New Project appeared first on Monsieur Winner.

]]>
It’s August 2024, and I am trying to create a create a new Azure DevOps project for a new Dynamics 365 Finance implementation project. It turns out TFVC is not available anymore as a version control. This is coming after Microsoft published  Git walkthrough for D365 Finance & Supply chain implementation.

Hence , create a new Azure DevOps project would have you choose Git as default version control and TFVC is totaly missing.. This tell us we need to start using this for future project and obviously migrate current D365FO repositories from TFVC to Git.

If you probably are not ready to start using Git, fear not :). At least for now, you can enable the TFVC option form the organization’s setting.

You should have it turned off as shown above.

 

Missing TFVC Option in Azure DevOps

The post Missing TFVC Option in Azure DevOps: Creating a New Project appeared first on Monsieur Winner.

]]>
https://blog.monsieurwinner.com/2024/08/07/missing-tfvc-option-in-azure-devops-creating-a-new-project/feed/ 0 733
How to convert from date to string using x++ https://blog.monsieurwinner.com/2024/08/06/how-to-convert-from-date-to-string-using-x/ https://blog.monsieurwinner.com/2024/08/06/how-to-convert-from-date-to-string-using-x/#respond Tue, 06 Aug 2024 19:39:47 +0000 https://blog.monsieurwinner.com/?p=730 The code below is written in D365FO. public Description dateInWord(TransDate _date) { Description day, month, year; day = int2Str(dayOfMth(_date)); month

The post How to convert from date to string using x++ appeared first on Monsieur Winner.

]]>
The code below is written in D365FO.

    public Description dateInWord(TransDate _date)
    {
        Description day, month, year;

        day = int2Str(dayOfMth(_date));
        month = mthName(mthOfYr(_date));
        Year  = int2Str(Year(_date));

        return strFmt("%1th %2, %3",day,month,Year);


    }

08/06/2024 ( MM/DD/YY) will is outputted as 6th August, 2024

The post How to convert from date to string using x++ appeared first on Monsieur Winner.

]]>
https://blog.monsieurwinner.com/2024/08/06/how-to-convert-from-date-to-string-using-x/feed/ 0 730
Default model for new projects in Visual studio D365FO https://blog.monsieurwinner.com/2024/02/27/default-model-for-new-projects-in-visual-studio-d365fo/ https://blog.monsieurwinner.com/2024/02/27/default-model-for-new-projects-in-visual-studio-d365fo/#respond Tue, 27 Feb 2024 22:23:32 +0000 https://blog.monsieurwinner.com/?p=706 While creating a new Project in D365FO, you will agree with me that, the default model is the famous FleetManagement. To

The post Default model for new projects in Visual studio D365FO appeared first on Monsieur Winner.

]]>
While creating a new Project in D365FO, you will agree with me that, the default model is the famous FleetManagement.

To set your custom model as default, go to

C:\Users\XYZ\Documents\Visual Studio Dynamics 365

 

Edit the DynamicsDevConfig file.

 

<DefaultModelForNewProjects>FleetManagement</DefaultModelForNewProjects>

Change FleetManagement to your custom model.

The post Default model for new projects in Visual studio D365FO appeared first on Monsieur Winner.

]]>
https://blog.monsieurwinner.com/2024/02/27/default-model-for-new-projects-in-visual-studio-d365fo/feed/ 0 706
OnActivated form method EventHandler X++ D365FO https://blog.monsieurwinner.com/2024/02/13/onactivated-form-method-eventhandler-x-d365fo/ https://blog.monsieurwinner.com/2024/02/13/onactivated-form-method-eventhandler-x-d365fo/#respond Tue, 13 Feb 2024 22:50:03 +0000 https://blog.monsieurwinner.com/?p=701 Here is a simple snippet of the active method on form by Event handler. Why use the active method ?

The post OnActivated form method EventHandler X++ D365FO appeared first on Monsieur Winner.

]]>
Here is a simple snippet of the active method on form by Event handler.

Why use the active method ?

We want to show record in a particular field on a grid when a record is selected.

In my case, we want to display the Department code on Positions:

Human resources -> Positions -> All positions.

 

The business scenario here is, the human resources officer is more familiar with the Department code. To achieve this, we can add a new field and assign the department code on selection of the record.

Let’s create a class: A form event handler for HcmPosition form.

internal final class HcmPosition_Form_GEMS_Handler
{

}

 

 

internal final class HcmPosition_Form_GEMS_Handler
{
 /// <summary>
 ///
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 [FormDataSourceEventHandler(formDataSourceStr(HcmPosition, HcmPositionDetail), FormDataSourceEventType::Activated)]
 public static void HcmPositionDetail_OnActivated(FormDataSource sender, FormDataSourceEventArgs e)
 {
   FormRun form = sender.formRun();
   FormDataSource HcmPositionDetail_ds = form.dataSource(formDataSourceStr(HcmPosition, HcmPositionDetail)) as FormDataSource;
   HcmPositionDetail hcmPositionDetail = HcmPositionDetail_ds.cursor();
   OMOperatingUnit operatingUnit;

   select operatingUnit where operatingUnit.RecId == hcmPositionDetail.Department;

   hcmPositionDetail.OMOperatingUnitNumber = operatingUnit.OMOperatingUnitNumber;
 }

}

The post OnActivated form method EventHandler X++ D365FO appeared first on Monsieur Winner.

]]>
https://blog.monsieurwinner.com/2024/02/13/onactivated-form-method-eventhandler-x-d365fo/feed/ 0 701
D365FO Cloud hosted environment deployment warning 95017 https://blog.monsieurwinner.com/2023/11/23/pipelines-are-disabled-project/ https://blog.monsieurwinner.com/2023/11/23/pipelines-are-disabled-project/#respond Thu, 23 Nov 2023 20:58:31 +0000 https://blog.monsieurwinner.com/?p=690 While deploying a Build & Test environment recently, I got following warning on the LCS deployment page event though the environment status

The post D365FO Cloud hosted environment deployment warning 95017 appeared first on Monsieur Winner.

]]>
While deploying a Build & Test environment recently, I got following warning on the LCS deployment page event though the environment status showed deployed.

Warning tells me that my new D365FO environment is fine, however some automated setup are not completed in Azure DevOps.

 

AddTrustedTestCertificateToWifConfig: Could not reach desired state
LCS DEPLOYMENT PAGE

 

 

Script [Run-CommandALMServiceInstallALM] failed execution against VM [XXXX]. Last Result: 0xA01604AF (An error occurred during the build environment setup process. Error details: ALM service model configuration failed. Configuration has 2 errors:
[1] BuildEnvironmentReadiness: PowerShell DSC resource MSFT_ScriptResource failed to execute Set-TargetResource functionality with error message: {“$id”:”1″,”innerException”:null,”message”:”The classic pipelines are disabled for this project / organization.”,”typeName”:”System.InvalidOperationException, mscorlib, Version=14.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089″,”typeKey”:”InvalidOperationException”,”errorCode”:0,”eventId”:0}
[2] AddTrustedTestCertificateToWifConfig: Could not reach desired state. [One or more dependencies may have failed.])

 

The first error made sense when we check the Azure DevOps project. I discovered that Disable creation of classic build pipelines was turned on.

During the deployment of a new Build environment, a build agent and a classic build pipeline are created/imported. So disabling creation of classic pipeline will surely result into error.

The post D365FO Cloud hosted environment deployment warning 95017 appeared first on Monsieur Winner.

]]>
https://blog.monsieurwinner.com/2023/11/23/pipelines-are-disabled-project/feed/ 0 690
Dual write error – missing prvReadmsdyn_paymentschedule privilege for entity ‘msdyn_paymentschedule’ https://blog.monsieurwinner.com/2023/09/25/dual-write-error-missing-prvreadmsdyn_paymentschedule-privilege-for-entity-msdyn_paymentschedule/ https://blog.monsieurwinner.com/2023/09/25/dual-write-error-missing-prvreadmsdyn_paymentschedule-privilege-for-entity-msdyn_paymentschedule/#respond Mon, 25 Sep 2023 22:24:14 +0000 https://blog.monsieurwinner.com/?p=654 During dual write setup, there are few things to do fully have the syn up and running. Either you are

The post Dual write error – missing prvReadmsdyn_paymentschedule privilege for entity ‘msdyn_paymentschedule’ appeared first on Monsieur Winner.

]]>
During dual write setup, there are few things to do fully have the syn up and running. Either you are settting up dual write for the first time or doing a reset, you need to make sure that the dual write user belongs to a Team that has the adequate role to perform the data Synchronization, else you would end up error such as:

missing prvReadmsdyn_paymentschedule privilege (Id=59c99a27-eae9-49e1-8204-e28e3600139f) on OTC=11187 for entity ‘msdyn_paymentschedule’ (LocalizedName=’Payment Schedule’) in Business Unit: (Id=699a433e-f36b-1410-81cd-00c87dfd4262). context.Caller=987b2374-02d9-ed11-a7c7-0022489ae673. Consider adding missed privilege to one of the principal (user/team) roles.

Locate the team with the id shown in the error, (709a433e-f36b-1410-81cd-00c87dfd4262) in my case and assign the system administrator right on Dynamics D354/CE

 

This will resolve the missing privilege for entity ‘msdyn_paymentschedule’ error.

That’s it! You should be free like a bird.

The post Dual write error – missing prvReadmsdyn_paymentschedule privilege for entity ‘msdyn_paymentschedule’ appeared first on Monsieur Winner.

]]>
https://blog.monsieurwinner.com/2023/09/25/dual-write-error-missing-prvreadmsdyn_paymentschedule-privilege-for-entity-msdyn_paymentschedule/feed/ 0 654
Account category or AX is a company-specific entity with primaryCompanyField set to DataAreaId and new_accountcategories of CRM is a cross-company entity that doesn’t have primary company field set. Please make sure the entities are both cross-company or company-specific entities. https://blog.monsieurwinner.com/2023/09/21/account-category-or-ax-is-a-company-specific-entity-with-primarycompanyfield-set-to-dataareaid-and-new_accountcategories-of-crm-is-a-cross-company-entity-that-doesnt-have-primary-company-field-set/ https://blog.monsieurwinner.com/2023/09/21/account-category-or-ax-is-a-company-specific-entity-with-primarycompanyfield-set-to-dataareaid-and-new_accountcategories-of-crm-is-a-cross-company-entity-that-doesnt-have-primary-company-field-set/#respond Thu, 21 Sep 2023 23:24:03 +0000 https://blog.monsieurwinner.com/?p=649 Bonjour les amis. Using dual write recently, we had cause to create custom entities on Both CE and FO. While

The post Account category or AX is a company-specific entity with primaryCompanyField set to DataAreaId and new_accountcategories of CRM is a cross-company entity that doesn’t have primary company field set. Please make sure the entities are both cross-company or company-specific entities. appeared first on Monsieur Winner.

]]>
Bonjour les amis.

Using dual write recently, we had cause to create custom entities on Both CE and FO.

While setting up the mapping , we got the error :

Account category or AX is a company-specific entity with primaryCompanyField set to DataAreaId and new_accountcategories of CRM is a cross-company entity that doesn’t have primary company field set. Please make sure the entities are both cross-company or company-specific entities.

This is simply because my custom table support cross company data sharing as stated in Microsoft documentation:

To resolve the error we can do the following:

1 . Go to Dataverse and add a new field (company) to our custom table.

2 . Add a new Key with Colum Company

 

and lastly

3 . Set the newly added field as an entity key on Dual write.

 

Voila!

The post Account category or AX is a company-specific entity with primaryCompanyField set to DataAreaId and new_accountcategories of CRM is a cross-company entity that doesn’t have primary company field set. Please make sure the entities are both cross-company or company-specific entities. appeared first on Monsieur Winner.

]]>
https://blog.monsieurwinner.com/2023/09/21/account-category-or-ax-is-a-company-specific-entity-with-primarycompanyfield-set-to-dataareaid-and-new_accountcategories-of-crm-is-a-cross-company-entity-that-doesnt-have-primary-company-field-set/feed/ 0 649
Cannot create a record in Entity (DMFEntity) D365FO https://blog.monsieurwinner.com/2023/08/16/cannot-create-a-record-in-entity-dmfentity-d365fo/ https://blog.monsieurwinner.com/2023/08/16/cannot-create-a-record-in-entity-dmfentity-d365fo/#respond Wed, 16 Aug 2023 10:26:21 +0000 https://blog.monsieurwinner.com/?p=645 Building a new custom data entity is one of the many requests you get while working on a D365FO Project.

The post Cannot create a record in Entity (DMFEntity) D365FO appeared first on Monsieur Winner.

]]>
Building a new custom data entity is one of the many requests you get while working on a D365FO Project.

This happens often when an already data entity is modified. Upon synchronization, the table DMFEntity gets updated with the updated data entity. Meanwhile, the DMFEntity table has the EntityName as a primary Key.

Resolution:

Delete all records in DMFEntity via the SQL Studio.

The post Cannot create a record in Entity (DMFEntity) D365FO appeared first on Monsieur Winner.

]]>
https://blog.monsieurwinner.com/2023/08/16/cannot-create-a-record-in-entity-dmfentity-d365fo/feed/ 0 645
Warning:[DWCE0001] Export was skipped. Max lookup count supported in Initial Sync stage is 10. Current lookup count 11. https://blog.monsieurwinner.com/2023/08/14/warningdwce0001-export-was-skipped-max-lookup-count-supported-in-initial-sync-stage-is-10-current-lookup-count-11/ https://blog.monsieurwinner.com/2023/08/14/warningdwce0001-export-was-skipped-max-lookup-count-supported-in-initial-sync-stage-is-10-current-lookup-count-11/#respond Mon, 14 Aug 2023 21:19:18 +0000 https://blog.monsieurwinner.com/?p=641 Via dual write, while copying data from the Dataverse to Dynamics 365FO via initial sync and I go this error:

The post Warning:[DWCE0001] Export was skipped. Max lookup count supported in Initial Sync stage is 10. Current lookup count 11. appeared first on Monsieur Winner.

]]>
Via dual write, while copying data from the Dataverse to Dynamics 365FO via initial sync and I go this error:

 

Warning:[DWCE0001] Export was skipped. Max lookup count supported in Initial Sync stage is 10. Current lookup count 11. Lookup fields:

transactioncurrencyid.isocurrencycode,

msdyn_customergroupid.msdyn_groupid,

msdyn_billingaccount.accountnumber,

msdyn_paymentday.msdyn_name,

msdyn_customerpaymentmethod.msdyn_name,

msdyn_paymentschedule.msdyn_name,

msdyn_paymentterm.msdyn_name,

msdyn_vendor.msdyn_vendoraccountnumber,

primarycontactid.msdyn_contactpersonid,

msdyn_salestaxgroup.msdyn_name,

msdyn_company.cdm_companycode.

To fix the issue refer to https://docs.microsoft.com/en-us/powerapps/developer/data-platform/webapi/retrieve-related-entities-query

 

After few checks here and there, it turns out that, there is a limitation when copying data from Dataverse. The entity must not have a table map lookups more than 10 as stated on MS Learn

 

Resolution:

Like the error message says, we need to remove one mapping ( a non-mandatory one). So what I did was to delete the Payment day mapping, did initial Sync successfully then re-added the field mapping.

 

 

 

The post Warning:[DWCE0001] Export was skipped. Max lookup count supported in Initial Sync stage is 10. Current lookup count 11. appeared first on Monsieur Winner.

]]>
https://blog.monsieurwinner.com/2023/08/14/warningdwce0001-export-was-skipped-max-lookup-count-supported-in-initial-sync-stage-is-10-current-lookup-count-11/feed/ 0 641