Search This Blog

Showing posts with label D365FO. Show all posts
Showing posts with label D365FO. Show all posts

Tuesday, August 23, 2022

How to create label or label file in Dynamics 365 Finance and Operation

In the Dynamics 365 Finance and Operation, for each hard code string, we need to create the label for that like Label on the Extended data type, Base enums, Menu items, Caption on the forms or any other string used to create the info, warning or error in the code. There are more scenario, where we need to create label instead of hard code. 

Label support language translation as well so that when user change the language so that user can see all the labels on the front end in respective language. 

To create the label, first we need to create the label file. Every model should a label file. 

How to create label file

To create label file, Just right click on your project and click add new time and select the label file as per below screenshot. 

Click next 


Click next 



By default en-us will be selected. you can select the multiple language based on your requirement and click on next. 

it will show you the summary



click next and label file has been created.

when you double click the created label file, it will show you the below grid. 
here you can create the new label id and copy it and paste in your code or on the object properties. for example, below label id will be 

@FOTraining:NewLabel0






Every time while creating the label, we should search the existing label and we can use it. 


Monday, August 1, 2022

Create lookup method using x++ in Dynamics 365 FO

 void lookup(FormStringControl _control)

    {

        SysTableLookup  tableLookup = SysTableLookup::newParameters(tableNum(EntAssetObjectTable), _control);


        Query                   query           = new Query();

        QueryBuildDataSource    qbdsAssetTable  = query.addDataSource(tableNum(EntAssetObjectTable));


        tableLookup.parmQuery(query);

        tableLookup.addLookupfield(fieldNum(EntAssetObjectTable, SerialID));

        tableLookup.addLookupfield(fieldNum(EntAssetObjectTable, ObjectID));

        tableLookup.addLookupfield(fieldNum(EntAssetObjectTable, Name));        

    

        tableLookup.performFormLookup();

    }

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

            }          

        }

    }

}