Posts

Running x++ scripts and jobs in an environment with 0 downtime

Image
  This blog post is about exploring the new Microsoft feature that allows you to run X++ jobs on PROD and non-PROD environments without release and with 0 downtime. In 10.0.25 you can run simple X++ scripts on a production environment without any downtime. This feature lets you run custom X++ scripts without having to go through Dynamics LCS or suspend your system. Therefore, you can correct minor data inconsistencies without causing any disruptive downtime. To be able to use this feature   you need to create a deployable package with ONLY ONE runnable class in it. To do this,   you can create a new model and reference the models which object you will use in the X++ script.   Dynamics365->Model Management -> Create Model Ex: CutomModel  Then create the runnable class and generate a deployable package from Visual Studio only with your new model that has only one runnable X++ class. class SLWrongVendorRunnableClass {          ...

Restore/Import Database with RETAIL functionality

Image
  Restoring a Dynamics 365 finops database has become much easier with the export database functionality in LCS. More details   here   With the new feature in LCS the database is exported out of Azure SQL and a bacpac file is added to the asset library After the database is exported the database file can be seen in the Asset library. The following steps can be used to import the database to development environment for Retail testing/debugging   1) Restore the bacpac file   SqlPackage.exe /a:import /sf:D:\EXPORTED-DB.bacpac /tsn:localhost /tdn:AxDB_Copy /p:CommandTimeout=1200   2) Stop the world wide publishing service, Batch, DIXF and management reporter service   3) Rename the original database to AXDB_Orig and database imported to AxDB   4) Start the services stopped in step2.   5) In the imported database the change tracking will automatically be turned off at database level. Enable change tracking on AxDB. This can be easily done fro...

Export a copy of the standard user acceptance testing (UAT) database

 https://docs.microsoft.com/en-us/dynamics365/fin-ops-core/dev-itpro/database/dbmovement-scenario-exportuat Import the database: Keep a copy of the existing AxDB database, so that you can revert to it later if you must. Import the new database under a new name, such as  AxDB_fromProd . Open a  Command Prompt  window, and run the following commands from the sqlpackage .NET Core folder. Download sqlpackage .NET Core for Windows from  Get sqlpackage .NET Core for Windows .  SqlPackage.exe /a:import /sf:D:\Exportedbacpac\my.bacpac /tsn:localhost /tdn:<target database name> /p:CommandTimeout=1200 Update the database Remember to edit the final  ALTER DATABASE  statement so that it uses the name of your database. CREATE USER axdeployuser FROM LOGIN axdeployuser EXEC sp_addrolemember 'db_owner', 'axdeployuser' CREATE USER axdbadmin FROM LOGIN axdbadmin EXEC sp_addrolemember 'db_owner', 'axdbadmin' CREATE USER axmrruntimeuser FROM LOGIN axmrruntimeus...

The transaction log for database 'AXDB' is full due to 'LOG_BACKUP'

 USE AXDB;   GO   -- Truncate the log by changing the database recovery model to SIMPLE.   ALTER DATABASE AXDB SET RECOVERY SIMPLE;   GO   -- Shrink the truncated log file to 50 MB.   DBCC SHRINKFILE (ProdAXDB_log, 50);   GO   -- Reset the database recovery model.   ALTER DATABASE AXDB SET RECOVERY FULL;   GO

Get display value from ledger dimension in D365FO

  Last time, I have shared the code about how to   Get Main Account from Ledger Dimension in D365FO . In this article, I am sharing the one line code to get the display value using   LedgerDimensionFacade class . See the following code: //Get Display value from LedgerDimension //The argument (LedgerDimensionValue) is LedgerDimension which you can get from table or any other source as per your requirement info(strFmt("%1",LedgerDimensionFacade::getDisplayValueForLedgerDimension(LedgerDimensionValue)));

Get main account from ledger dimension in D365FO

  In this article, you will get the one line code to get the Main Account from Ledger Dimension using   LedgerDimensionFacade class . See the following code: //Get MainAccountId from LedgerDimension //The argument (LedgerDimensionValue) is LedgerDimension which you can get from table or any other source as per your requirement info(strFmt("%1",LedgerDimensionFacade::getMainAccountFromLedgerDimension(LedgerDimensionValue).MainAccountId)); //Get Name of MainAccountId from LedgerDimension //The argument (LedgerDimensionValue) is LedgerDimension which you can get from table or any other source as per your requirement info(strFmt("%1",LedgerDimensionFacade::getMainAccountFromLedgerDimension(LedgerDimensionValue).Name));

Assign default values to form in D365FO

  Scenario: I am assigning a value to a field in HcmEmploymentLeave form using OnInitValue form data source event handler. Lets start! Run  Visual Studio Search your desired form in  Application Explorer Right click the form -> click  Open designer Expand the  Data Sources node Expand your  desired data source node  ->  Events  -> Select  OnInitValue event  ->  Right click and copy event handler method Create a  new class Paste  the event handler method Add code  in it like below: [FormDataSourceEventHandler(formDataSourceStr(HcmEmploymentLeave, HcmEmploymentLeave), FormDataSourceEventType::InitValue)] public static void HcmEmploymentLeave_OnInitValue(FormDataSource sender, FormDataSourceEventArgs e) { FormRun formRun = sender.formRun(); Object hcmEmploymentLeave_ds = formRun.dataSource(formDataSourceStr(HcmEmploymentLeave, HcmEmploymentLeave)) as FormDataSource; HcmEmploymentLeave hcmE...
  How to: Create Query with Range through X ++ I had a hard time trying to find how use range between dates so I hope to help not only who wants to create a query but also who wants to know how to use range with date. 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 // Create a new Job static void CustDateRangeQuery(Args _args) {      Query                   query;      QueryRun                queryRun;      QueryBuildDataSource    qbds;      QueryBuildRange         qbr;      CustTable               custTable;      ; ...