Posts

x++ code for Sending Email Notification whenever sales order is confirmed, cancelled, delivered or invoiced

  please use this account Details:- User ID : - svc_admin@basofa.onmicrosoft.com Password : - Zac00247 [ExtensionOf(tableStr(SalesTable))] final class BASSalesTable_Extension {     public void update()     {         SalesTable salesTable = this.orig();         next update();         if(salesTable.DocumentStatus != this.DocumentStatus || (this.SalesStatus == SalesStatus::Canceled && this.SalesStatus != salesTable.SalesStatus))         {                     SysEmailParameters _SysEmailParameters;             var builder = new SysMailerMessageBuilder();             select SMTPUserName from _SysEmailParameters;                 builder.setFrom(_SysEmailParameters.SMTPUserName);             bui...

X++ code to upload files from Dynamics 365 to Azure Blob Storage

using BlobStorage = Microsoft.WindowsAzure.Storage; using Microsoft.Dynamics.AX.Framework.FileManagement; using System.IO; class RunnableClass3 {     /// <summary>     /// Runs the class with the specified arguments.     /// </summary>     /// <param name = "_args">The specified arguments.</param>     public static void main(Args _args)     {         CommaStreamIo       io = CommaStreamIo::constructForWrite();         CustTable           custTable;         const str           connectionString = "DefaultEndpointsProtocol=https;AccountName=sarathbujala;AccountKey=6bCwPjV6Co3bIFgOTv6sQs+/rnXbcJbwe1gPfRofTH8zBXy0AteMv34xruT0pSrUu5V0ZxO8Li4X+AStVXATBQ==;EndpointSuffix=core.windows.net";         const str           containe...

x++ code to send messages from dynamics 365 to azure service queue

 step1 : Create a Runnable Class (Job) class BAS_SendMessageToAzure {     /// <summary>     /// Runs the class with the specified arguments.     /// </summary>     /// <param name = "_args">The specified arguments.</param>     public static void main(Args _args)     {          //Azure connection string         str connectionString = 'Endpoint=sb://basofaservicebus.servicebus.windows.net/;SharedAccessKeyName=Manage;SharedAccessKey=YRLWqKSymqC/ghx1e9U7q/5ZVhd5t7Uqc+ASbCPeIl0=';          // queue name         str queueName = 'test-queue';          System.IO.StringWriter          stringWriter; // used to manipulate and generate text data.         Newtonsoft.Json.JsonTextWriter  jsonWriter; // used to write data in json format     ...

X++ code to get /Print error messages in D365FO of any operations

  This code will help us to fetch /get inner exceptions or errors  1. To get error messages  class BASMSGetErrorJob {     /// <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)     {     SysInfoLogEnumerator        infoLogEnum;     SysInfologMessageStruct     infoMessageStruct;     List                        errorList = new List(Types::String);           try         {        //Logic   //Declaration of data entities    ...

X++ code to fetch the system errors

  Description :-  This class will help you to fetch the error which occurs in system while doing any operation in D365FO class BASMSGetErrorMsgJob {         /// <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)     {         SysInfoLogEnumerator        infoLogEnum;         SysInfologMessageStruct     infoMessageStruct;         List                        errorList = new List(Types::String);         try         {       ...

X++ code to write SysOperation framework using AOT Queries

Data Contract Class : [DataContractAttribute] class ARF_DispatchTrackOrderDataContract extends ARF_DispatchTrackQueryDataContract {     [DataMemberAttribute,      AifQueryTypeAttribute('_encodedQuery',      queryStr(ARF_SalesTableQuery))  // simple query name     ]     public str parmEncodedQuery(str _encodedQuery = encodedQuery)     {         return super(_encodedQuery);     } }  Base data contract class ARF_DispatchTrackQueryDataContract {     str         encodedQuery;     QueryName   queryName;       public Query createQuery()     {         Query query = new Query(this.queryName());         return Query;     }     public str parmEncodedQuery(str _encodedQuery = encodedQuery)     {         encodedQuery = _enco...

X++ code to create Price Simulator Custom Service in D365 F&O

Request Class : [DataContractAttribute("BAS_PriceSimulatorContract")] class BAS_PriceSimulatorContract {     str            itemNumber;     str            dataAreaId;     str            channelId;     TransDateTime  channelDateTime;     CurrencyCode   currencyCode;     str            catalogs;     int            quantity;     str            customerAccount;     str            affiliations;     str            loyalityTiers;     str            couponCodes;     str            priceGroups;     [DataMemberAttribute("itemNumber")]     public str ...