Posts

Downloading Files from FTP and Doing Something With Them In D365FO

  Although D365FO is now thoroughly modern and web based, with all the good things that entails, we still have to interface with some less modern systems. Sometimes those systems are literally older than we are. There are some middleware solutions that can help bridge the gap but we have quite a few tools in D365FO that can help us. Let's talk about FTP for a bit. The tried and true battle horse of Odin himself, this is never going to go away, ever. So, let's see what we can do from inside D365FO with no C# in play; just some standard tools available from x++. Consider the very simple example: using System.Net; class AAX_FTPDownloadSimple {     public static void main(Args args)     {         System.Net.WebClient webClient = new System.Net.WebClient();         webClient.Credentials = new NetworkCredential("userName", "password");         webClient.DownloadFile(" ftp://nadummy.sharefileftp.com/test/test.txt ", @"C:\temp\test.txt");        

D365 – Data Entity Method Call Sequence

Image
  1. initValue 2. validateField 3. validateWrite 4. update 4.1. doUpdate 4.1.1. persistEntity 4.1.1.1. doPersistEntity 4.1.1.1.1. initializeDataSources 4.1.1.1.1.1. initializeEntityDataSource Note: initializeDataSource is called once for each DataSource in Entity. 4.1.1.1.2. mapEntityToDataSources Note: initializeDataSource is called once for each DataSource in Entity. 4.1.1.1.3. saveDataSources 4.1.1.1.3.1. updateEntityDataSource 4.1.1.1.4. mapEntityToDataSource (maybe for another record) 4.1.1.1.5. saveDataSources 4.1.1.1.5.1. updateEntityDataSource for update operation and (insertEntityDataSource for insert) 4.1.1.1.5.1.1. mapDataSourceToEntity 4.1.1.1.5.1.2. doSaveDataSource 4.1.1.1.5.1.2.1. updateDataSource 4.1.1.1.5.1.2.1.1. preupInsertDataSource 4.1.1.1.5.1.2.1.1.1. validateWrite of table Plus: postLoad This method is called during the export for setting the value to unmapped fields after entity is downloaded to datasource. EXPORT:        Entity- postLoad()        staging - inse

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 {          /// <summary>     /// Class entry point. The sys

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 from database properties in a Tier 1 environment.  

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 axmrruntimeuser EXEC

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)));