Posts

Get UTC time in IST

 Below is the code snippet which helps to get UTC date and time in Indian Standard Time (+5.30) System.TimeZoneInfo timeZone = System.TimeZoneInfo::FindSystemTimeZoneById("India Standard Time");  System.DateTime localTime = System.TimeZoneInfo::ConvertTimeFromUtc(System.DateTime::UtcNow, timeZone); // Convert from utc to IST.  Info(strFmt("Local Time: %1", localTime.ToString("MM/dd/yyyy")));  Info(strFmt("Local Time: %1", localTime.ToString("dddd, dd MMMM yyyy")));  Info(strFmt("Local Time: %1", localTime.ToString("MMMM dd")));  Info(strFmt("Local Time: %1", localTime.ToString("dddd, dd MMMM yyyy HH:mm:ss")));  Info(strFmt("Local Time: %1", localTime.ToString("MM/dd/yyyy HH:mm")));  Info(strFmt("Local Time: %1", localTime.ToString("MM/dd/yyyy hh:mm tt")));  Info(strFmt("Local Time: %1", localTime.ToString("MM/dd/yyyy H:mm")));  Info(strFm...

X++ code to refresh the caller form in D365FO

 Below is the code snippet to refresh the caller form from class Main method. X++ code:    #Task    FormRun caller = _args.caller();    if (caller)     {           caller.task(#taskRefresh);      }

Export Data Packages using Data Management and Postman in D365FO

Image
 Steps to export data packages using data management framework and Rest API in D365FO  Step 1: Create a new data export project using DMF. This project should include the data entities which are required for the export. Step 2: Export the package using postman, To do it, Mainly we need below 3 information. {{ D365URL }} : Dynamics 365 URL DefinitionGroupId : DMF Project name packageName : Name of the export package REST API URL:  {{D365URL}} /data/DataManagementDefinitionGroups/Microsoft.Dynamics.DataEntities.ExportToPackage Body: Response from Postman: Upon execution success, Postman will provide a  response indicating that the export has been initiated. Step 3: Check export package status using the API {{D365URL}} /data/DataManagementDefinitionGroups/Microsoft.Dynamics.DataEntities.GetExecutionSummaryStatus and the Body Response of the API call: Step 4: Download the Package. To download the exported package, run the the below API and Body. The response will provid...

X++ code to get sales order totals in D365FO

 Below is the code snippet to get sales totals of open order and invoiced sales orders Open order Sales Orders:    container displayFields = S alesTotals::displayFieldsServer (salesTable, SalesUpdate::All, "");   real totalAmountIncTax  = conpeek(displayFields, TradeTotals::posTotalAmount());   real totalAmountExcTax  = conPeek(displayFields, TradeTotals::posBalance());   real totalAmountTax     = conpeek(displayFields, TradeTotals::posTaxTotal()); Invoiced Sales Orders:  SalesQty    qty; Amount      totalAmountIncTax,totalAmountTax,totalAmountExcTax; [totalAmountIncTax,totalAmountTax,totalAmountExcTax,qty] = ANI_SalesEventHandlers::getSalesInvoiceAmountAndTax(salesTable); real totalAmountExcTax = totalAmountExcTax; real totalAmountIncTax = totalAmountIncTax; real totalAmountTax    = totalAmountTax;      /// <summary>     /// Get Invoiced Sales Order Amount, tax,...

Generate all days of a month in Excel

Image
  Formula to get Number of days in the month (B2): =DAY(EOMONTH(B1,0)) Formula to generate all the days:  =DATE(YEAR(B1),MONTH(B1),SEQUENCE(B2))

Copy attachments from sales order to production order while firming planned production order in D365FO

 In D36FO, it is common requirement to copy documents from one table to another table. Here is an example to copy documents of type "Note" from Sales order to production order during firming and Also update/delete the records in planned order if the document attachment is updated/deleted in sales order. code snippets: /// <summary> /// Extension methods for the <C>ReqTransPOMarkFirm</C> class. /// </summary> [ExtensionOf(classStr(ReqTransPOMarkFirm))] internal final class ANI_ReqTransPoMarkFirm_Extension {     protected ProdTable createProdTable(         ReqTrans    _reqTrans,         ReqPO       _reqPO,         ProdBOM     _prodBOMParent)     {         ProdTable prodTable = next createProdTable(_reqTrans,_reqPO,_prodBOMParent);         if (prodTable && prodTable.InventRefType == InventRe...

Get running Select statement from Query during runtime in D365FO

  Syntax:  info(new query(queryStr(QueryName)).toString()); Example: info(new query(queryStr(Customer)).toString());