Search This Blog

Tuesday, July 26, 2022

Method execution sequence of an Entity while record creation in Dynamics 365 Finance and operation

This is how method will execute when record will be created from DIXF using data entity. It also includes the methods related to tables as well.

 

In data entity before super postLoad

 In data entity after super postLoad

 In data entity before super initValue

 In data entity before super postLoad

 In data entity after super postLoad

 In data entity after super initValue

 In data entity before super validateField

 In data entity before super validateFieldValue

 In data entity after super validateFieldValue

 In data entity after super validateField

 In data entity before super validateField

 In data entity before super validateFieldValue

 In data entity after super validateFieldValue

 In data entity after super validateField

 In data entity before super validateField

 In data entity before super validateFieldValue

 In data entity after super validateFieldValue

 In data entity after super validateField

 In data entity before DefaultRow

 In data entity after defaultRow

 In data entity before super validateWrite

 In data entity after super validateWrite

 In data entity before super insert

 In data entity before super persistEntity

 In data entity before super initializeEntityDataSource

 In table before super initValue

 In table before super postLoad

 In table after super postLoad

 In table after super initValue

 In data entity after super initializeEntityDataSource

 In data entity before super mapEntityToDataSource

 In data entity after super mapEntityToDataSource

 In data entity before super insertEntityDataSource

 In table before super validateField

 In table before super validateFieldValue

 In table after super validateFieldValue

 In table after super validateField

 In table before super validateField

 In table before super validateFieldValue

 In table after super validateFieldValue

 In table after super validateField

 In table before super validateField

 In table before super validateFieldValue

 In table after super validateFieldValue

 In table after super validateField

 In table before super defaultRow

 In table after super defaultRow

 In table before super validateWrite

 In table after super validateWrite

 In table before super insert

 In table after super insert

 In data entity before super mapDataSourceToEntity

 In data entity after super mapDataSourceToEntity

 In data entity after super insertEntityDataSource

 In data entity after super persistEntity

 In data entity after super insert


Friday, July 1, 2022

How to download file from Azure Blob using x++ in D365 FO

Create the storage account on the azure as per below and copy the keys to connect to this storage account. 


Create a container inside this storage account named with dynamicsfocontainer. We can upload the files from our local directory. To download the files from blob container we can use the below code in the x++. Below is the runnable class that I have developed. 

You can use the exception as per your requirement and loop as well. 


using Microsoft.WindowsAzure.Storage;

using Microsoft.WindowsAzure.Storage.Blob;

 

internal final class CreateReadWriteBlobStorage

{

    /// <summary>

    /// Class entry point. The system will call this method when a designated menu

    /// is selected or when execution starts and this class is set as the startup class.

    /// </summary>

    /// <param name = "_args">The specified arguments.</param>

    public static void main(Args _args)

    {

        CloudStorageAccount  storageAccount;

        CloudBlobContainer   blobContainer;

        CloudBlobClient      blobClient;

 

        storageAccount = CloudStorageAccount::Parse("DefaultEndpointsProtocol=https;AccountName=dynamicsfinanceoperation;AccountKey=I1IFZ7bdzX61466bAxbNChJVN3PbtUgPfNH5WbXbnc8sTIXS/ffZmN0EDo+zbS+AStn3n0Pw==;EndpointSuffix=core.windows.net");

        blobClient = storageAccount.CreateCloudBlobClient();

       

        blobContainer = blobClient.GetContainerReference("dynamicsfocontainer");

 

        System.Collections.IEnumerable listEnumerable =  blobContainer.ListBlobs(null,true,0,null,null);

        System.Collections.IEnumerator listEnumerator = listEnumerable.GetEnumerator();

       

        while (listEnumerator.MoveNext())

        {

            IListBlobItem item = listEnumerator.Current;

 

            if (item is CloudBlockBlob)

            {

                CloudBlockBlob  blockBlob = item;

                System.IO.FileStream  localFile = System.IO.File::Create(@"C:\Temp\Blob\" + blockBlob.Name);

                blockBlob.DownloadToStreamAsync(localFile);

                Info(strFmt("%1",blockBlob.Name));

            }          

        }

    }

}