August 22, 2023

Disable export to Excel on forms - D365 FO

 We can disable the export to Excel option in list pages, there is an option on grid properties “Export to Excel”. By default, it is true. By changing it to false we can disable export to excel on specific form.

August 18, 2023

3rd Party API Consumption with D365FO

 Prerequisite:

       Identify the API name and purpose of API i.e., what it does?

       Identify the endpoints.

       Understand Request and Response JSON.

       Understand the attributes used and consumed.

       Understand the type of request i.e. GET, POST, PUT and Delete 

       Understand the criticality of each request.

       Understand the error codes provided when there is any issue.

       Get the details of the SSL Certificates which need to be utilized for consumption of API and how can it be configured.

       Understand If any IP Whitelisting is required and how can it be done.

       Understand if there is any signed legal agreement is required in API templates.

Basic Architecture:






August 10, 2023

D365FO: Read CSV file from Azure File Share

 using Microsoft.Azure;

using Microsoft.WindowsAzure.Storage;
using Microsoft.WindowsAzure.Storage.Blob;
using Microsoft.WindowsAzure.Storage.File;
 
class MAKCloudStorageFileManager
{
    #File
    #define.delimiterField(',')
 
    public static void main(Args _args)
    {
        #OCCRetryCount
 
        System.IO.MemoryStream memoryStream;
        System.String          storageAccountName;
        System.String          keyValue;
 
        CloudStorageAccount    storageAccount;
        CloudFileClient        fileClient;
        CloudFileShare         fileShare;
        CloudFileDirectory     fileDirectoryRoot;
        CloudFileDirectory     fileDirectory;
        CloudFile              file;
 
        TextStreamIo           textStreamIo;
        VendTable              vendTable;
        VATNum                 vendABN;
        Counter                counter;
        container              rec;
 
        storageAccountName     = "AzureStorageAccountName";
        keyValue               = "KeyValueString";
        var storageCredentials = new Microsoft.WindowsAzure.Storage.Auth.StorageCredentials(storageAccountName, keyValue);
        storageAccount         = new Microsoft.WindowsAzure.Storage.CloudStorageAccount(storageCredentials, true);
        fileClient             = storageAccount.CreateCloudFileClient();
        fileShare              = fileClient.GetShareReference('AzureFileShareName');
  
        if (fileShare.Exists(null, null))
        {
            fileDirectoryRoot = fileShare.GetRootDirectoryReference();
            fileDirectory     = fileDirectoryRoot.GetDirectoryReference("Folder/Subfolder");
  
            if (fileDirectory.Exists(null, null))
            {
                file = fileDirectory.GetFileReference('File.csv');
  
                if (file.Exists(null, null))
                {
                    memoryStream = new System.IO.MemoryStream();
                    file.DownloadToStream(memoryStream, null, null, null);
                    textStreamIo = TextStreamIo::constructForRead(memoryStream);
 
                    try
                    {
                        if (textStreamIo)
                        {
                            if (textStreamIo.status())
                            {
                                throw Global::error("@SYS52680");
                            }
 
                            textStreamIo.inFieldDelimiter(#delimiterField);
                            textStreamIo.inRecordDelimiter(#delimiterCRLF);
                            counter = 0;
 
                            while (!textStreamIo.status())
                            {
                                rec = textStreamIo.read();
 
                                if (conLen(rec))
                                {
                                    vendABN = conPeek(rec, 1);
 
                                    info(strFmt("%1", vendABN));
                                }
                            }
                        }
                    }
                    catch (Exception::Error)
                    {
                        error("An error occured. Please contact your system administrator.");
                    }
                }
            }
        }
    }
 
}