Posts

X++ code to generate SSRS Report Attachment in D365FO

 Below is the code snippet which helps to generate SSRS report as memory stream and then can be used it to send it through mail/upload in azure. public static System.IO.Stream generateAttachment(PurchTable _purchTable)     {         PurchTable purchTable = PurchTable::find(_purchTable.PurchId);         SrsReportRunController          ssrsController = new SrsReportRunController();         ANI_PurchPurchaseOrderContract      Contract = new ANI_PurchPurchaseOrderContract();//contract class         System.Byte[]    reportBytes = new System.Byte[0]();         SRSProxy    srsProxy;         SRSReportRunService    srsReportRunService = new SrsReportRunService();         Microsoft.Dynamics.AX.Framework.Reporting.Shared.ReportingService.ParameterValue[]   parameterV...

Odata Patch operation using Postman

Script to update records using Postman. By default, system will consider the legal entity associated with the user added in Microsoft Entra ID applications for postman client id. Patch Operation: Example: URL:  {D365URL}/data/{Entity name}(dataAreaId='abcd', Unique field= 5637182305)//  Body: {     "Comment": "Test" }

Remove Prefix from a String in D365FO

Code to remove any specified prefix from a string value. (Example: Remove '0' from '000018743') public static str stringWithoutPrefix(str _strValue,str _prefixToRemove)     {         str s1 = _strValue;         str s2 = _prefixToRemove;         int i = 0;         int whereFound;         for(i= 0; i < strlen(s1); i++)         {             whereFound = strnFind(s1, s2 , 1, strLen(s1));             if(whereFound > 1)             {                 s1 = strdel(s1,1,1);             }         }         return s1;     }

Send Purchase Orders to Vendor collaboration for Vendor Review in D365FO

 Code snippet to send purchase orders for external vendor review (in  Vendor collaboration module)             try             {                 PurchTable purchTable = PurchTable::find(PurchId);                   PurchFormLetter purchFormLetter = PurchFormLetter::construct(DocumentStatus::ConfirmationRequest);                   purchFormLetter.update(purchTable, strFmt("Sent for vendor review",purchTable.PurchId));             }             catch (Exception::Deadlock)             {              }