Skip to main content

Posts

D365 finops send attachment as public URL X++

D365 finops send attachment as public URL X++ A customer needs to download attachments from a mobile application that is connected to Dynamics 365 Finance and Operations (FinOps). I have created the following function in the Service to generate a public URL for the attachments. public str getPublicUrl(RecId _recid) {     DocuRef _ref;     select _ref where _ref.RecId == _recid && _ref.RefTableId == tableNum(PurchTable);     if (_ref.RecId)     {         return File::SendFileToTempStore(             DocumentManagement::getAttachmentStream(_ref),             ERDocuRef_Extension::filename(_ref),             classstr(FileUploadTemporaryStorageStrategy),             true         );     }     else     {         throw error("Attachment not found for the provided RecId.");     } }
Recent posts

Calling a new form method from Extension x++

I had a scenario where I had to call a new method in one of the fields from Vendor Payment Journal Line. The new method exists in Extension class of Vendor Payment journal.(which is a form method). This has to be called in modified method of the field ‘Ledger Dimension’. The steps are as follows [ExtensionOf(FormStr(LedgerJournalTransVendPaym))] final class LedgerJournalTransVendPaymFormExt_Extension { public void newMethod() { ………………. } } How do call this method in modified ? you have two choices – Create a event handler for the method or Chain of Commands. On using event handler, I ended up with error when I tried to call the new method using formRun. [FormDataFieldEventHandler(formDataFieldStr(LedgerJournalTransVendPaym, LedgerJournalTrans, LedgerDimension), FormDataFieldEventType::Modified)] public static void LedgerDimension_OnModified(FormDataObject sender, FormDataFieldEventArgs e) { FormDataSource ledgerJournalTrans_ds = sender.datasource(); FormRun

Error division by Zero

  AX / D365FO – How to prevent the error ‘Division by zero’ If you’re gonna write code like A = B /C, you better make sure that C holds a value. Of course you can do a check with a simple if-statement (if C then A = B/C), but there is an easier way. You can use  minOne , a method that exists in the Global class. int a,b,c; if(b) c = a / b; else print " Cannot divide by zero" OR c = a / c = a / minOne(b) ; //it returns a itself if b is zero because minOne() returns non zero values that we passes. I //it returns a itself if b is zero because minOne() returns non zero values that we passes. I f it is zero then it retuns 1

Filter records on form X++

  //Step 1 //Declare a class variable //In the ClassDeclaration method of form declare a QueryBuildRange class FormRun extends ObjectRun { QueryBuildRange q lobdr; } //Step 2 //Initialize this range in the init method of datasource after super() call. public void init() { super(); qbdr = InventSum_ds.queryBuildDataSource().addRange(fieldNum(InventSum, PhysicalInvent)); qbdr.value(queryValue('>0')); //range value, in this case filter records that have PhysicalInvent Qty > 0 InventSum_ds.executeQuery(); //execute Query } Ex: qbdr = InventSum_ds.queryBuildDataSource().addRange(fieldNum(InventSum, PhysicalInvent)); qbdr.value(queryValue(‘>0’)); qbdr.value(queryValue(‘>0’)); Could be written more compact as SysQuery::findOrCreateRange(InventSum_ds.queryBuildDataSource(),fieldNum(InventSum, PhysicalInvent)).value(queryValue(‘>0’));

Expired certificates renewal in D365FO

  AX / D365FO – Expired certificates renewal in D365FO Dynamics 365 for Finance and Operations on a local development environment may all of the sudden start reporting problems with the server due to expired certificates. To be sure, you should open the  Event Viewer , expand  Windows Logs  in the left pane and click on the  Application  node. Look for  Warning  logs with source  ASP.NET  and inspect their content. Therefore, when you’ll see  ExpiredCertificateException  under  Exception information , as seen in the image below, you’re dealing with expired certificates. Following the steps below, you will identify and extend required certificates to get access to Dynamics 365 for Finance and Operations again. Step 1: Identify Expired Certificates Start  Windows PowerShell  as administrator and enter the following two commands: cd cert:\LocalMachine\My ls | Select-Object NotAfter,Thumbprint,Subject | Where-Object -Property Subject -like "CN=DeploymentsOnebox.*" | Sort-Object -