Posts

Showing posts from January, 2024

Get Sales Quotation by Customer ID in X++ | Dynamics 365 FO Development

Creating a Sales Quotation using X++ code in Dynamics 365 Finance and Operations involves several steps. Below is an example of how you might achieve this. Please note that you may need to adapt the code to fit your specific requirements and the structure of your solution.   Please replace _custAccountId, _currencyCode, _itemId, and _qty with your actual values.   AxSalesQuotationTable     AxSalesQttable; AxSalesQuotationLine      AxSalesQtline; AxSalesQttable =   new AxSalesQuotationTable(); AxSalesQttable.parmCustAccount(_custAccountId); AxSalesQttable.parmCurrencyCode(_currencyCode); AxSalesQttable.save();   AxSalesQtline =   new AxSalesQuotationLine(); AxSalesQtline.axSalesQuotationTable(AxSalesQttable); AxSalesQtline.parmQuotationId(AxSalesQttable.parmQuotationId()); AxSalesQtline.parmItemId(_itemId); AxSalesQtline.parmSalesQty(_qty); AxSalesQtline.parmcurrencyCode(_currencyCode); AxSalesQtline.save();   This is a bas...

Retrieve default inventory dimensions for an item x++

  X++ code to retrieve default inventory dimensions for an item in Dynamics 365 Finance and Operations.   InventTable                  inventTable = InventTable::find('D0004'); InventItemOrderSetupType     setupType    = InventItemOrderSetupType::Invent; InventDim                    inventDim;   // Default Site inventDim.InventSiteId = inventTable.inventItemOrderSetupMap(setupType).inventSiteId(inventDim.InventSiteId, inventTable);   // Default Location inventDim.InventLocationId   = inventTable.inventItemOrderSetupMap(setupType, inventDim.InventDimId).inventLocationId(inventDim.InventLocationId, inventTable, inventDim.InventSiteId);   // Default ConfigId inventDim.ConfigId = inventTable.StandardConfigId;   // Find or create default item dimension inventDim = I...

Convert table rows to an XML string in X++ D365

To convert table rows to an XML string in X++, you can use the XMLWriter class to construct the XML document. Below is an example demonstrating how to achieve this:   Assuming you have a table named MyTable with fields Field1, Field2, and Field3, and you want to convert its rows to an XML string:   static void ConvertTableRowsToXml(Args _args) {      MyTable myTable;      XMLWriter xmlWriter;      XMLDocument xmlDocument;      str xmlString;        // Create a new XML document      xmlDocument = new XMLDocument();      xmlWriter = new XMLWriter(xmlDocument);        // Start the root element      xmlWriter.writeStartDocument();      xmlWriter.writeStartElement("Rows");       // Retrieve data from the table      while select * from myTable      {        ...

Convert table rows to JSON in X++ D365

To convert table rows to JSON in X++ , you can use the JSON serialization capabilities provided by X++'s built-in classes. Here's an example demonstrating how to achieve this:   Assuming you have a table named MyTable with fields Field1, Field2, and Field3, and you want to convert its rows to a JSON array:   static void ConvertTableRowsToJson(Args _args) {      MyTable myTable;      str jsonString;      int i;        // Create an empty array to store JSON objects      Array jsonArray = [];       // Retrieve data from the table      while select * from myTable      {          // Create a JSON object for each row          JsonObject jsonObject = new JsonObject();          jsonObject.addField("Field1", myTable.Field1);          jsonObject.addField("Field2", ...

Convert a sales quotation to a sales order in X++ D365

  To convert a sales quotation to a sales order in X++ , you typically create a new sales order header and lines based on the information from the existing sales quotation. Here's an example X++ code snippet: static void ConvertQuotationToSalesOrder(Args _args) {     SalesQuotationTable salesQuotationTable;     SalesQuotationLine salesQuotationLine;     SalesTable salesTable;     SalesLine salesLine;       ttsBegin;       // Replace 'YourQuotationId' with the actual quotation ID     salesQuotationTable = SalesQuotationTable::find('YourQuotationId');       if (salesQuotationTable)     {         // Create a new sales order header         salesTable.clear();         salesTable.initValue();         salesTable.CustAccount = salesQuotationTable.CustAccount;         salesTable.CurrencyCo...