Saturday, March 28, 2020

The option 4 for querystore query_capture_mode is not supported



It is caused due to a setup mismatch between AzureSQL and SQL server. To solve this issue you have to run this SQL statement
ALTER DATABASE [QueryStoreDB] SET QUERY_STORE (QUERY_CAPTURE_MODE = ALL); in the Azure SQL (UAT) environment before you export the database.
Other solution is: 
The solution is to rename the bacpac file to zip, extract the content and locate the "model.xml" file. Copy the "model.xml" file to a new location where you can locate it easily. Rename the zip file back to bacpac. Edit the "model.xml" file:
From:
<Property Name="QueryStoreCaptureMode" Value="4" />
To:
<Property Name="QueryStoreCaptureMode" Value="2" />
Save the "model.xml" file.
Now you need to use the "/ModelFilePath" parameter of SqlPackage.exe, and point it to your updated "model.xml" file. This will instruct the SqlPackage.exe to read the updated "model.xml" file and ignore the one from within the bacpac file.
After adding /ModelFilePath parameter of SqlPackage.exe, the command will look like this: 
C:\>"Program Files (x86)\Microsoft SQL Server\140\DAC\bin\SqlPackage.exe" /Action:Import /SourceFile:"bacpacfile" /mfp:"modelfilepath" /tsn:servername /tdn:dbname /p:CommandTimeout=1200

Wednesday, March 25, 2020

Copy Data of Custom fields from PurchLine to PurchaseOrderVersions


  1. Add fields by using table extensions to the PurchLine and PurchLineHistory tables.
  2. Create a new table map containing the fields that must be copied. 
  3. Implement the new table map on the two new table extensions.
  4. Create a new class to implement the PurchLineIVersioningFieldSet interface and implement the following required methods.
    • copyVersion method - Copies data between two records of the new table map type.
    • fieldSetTableMapId method - Returns the ID of the new table map.
    • isChangeConfirmationRequired method - Returns true or false based on whether the change to the newly added field values requires a confirmation to be created.
  5. Now run build + sync.

Customization Analysis Report (CAR) OR Check BP error using cmd in ax d365

Open command prompt as administrator and write below command to check BP error or car.



K:\AosService\PackagesLocalDirectory\bin\xppbp.exe -metadata=K:\AosService\PackagesLocalDirectory -all -model="ApplicationSuite" -xmlLog=C:\temp\BPCheckLogcd.xml -module="ApplicationSuite" -car=c:\temp\BPReport.xlsx

where ApplicationSuite = "YourModelName"

It will create an xml file named (BPCheckLodcd.xml) and excel file named (BPReport.xlsx) at location C:\temp. You can change this path according to you. This report is called Customization Analysis Report (CAR).

Monday, March 23, 2020

Run db sync using cmd in ax d365

Here is the command to run db sync using cmd in ax d365. Open command prompt as administrator and write the below code.

K:\> AosService\PackagesLocalDirectory\Bin\Microsoft.Dynamics.AX.Deployment.Setup.exe  -bindir "K:AosService\PackagesLocalDirectory"  -metadatadir K:AosService\PackagesLocalDirectory -sqluser username  -sqlserver  serverName  -sqldatabase databasename -setupmode sync -syncmode fullall -isazuresql false -sqlpwd pswd