Dynamic queries in D365 Finance & Operations

Dynamic queries

Scenario for the Dynamic queries in Dynamics 365 for Finance and Operations CODE public void dynamicQueries() { Query query = new Query(); QueryBuildDatasource qbdsPOLMobileServiceTable, qbdsPOLModelTable; QueryBuildRange qbrModelId; qbdsPOLMobileServiceTable = query.addDataSource(tableNum(POLMobileServiceTable)); qbdsPOLModelTable = qbdsPOLMobileServiceTable.addDataSource(tableNum(POLModelTable)); qbdsPOLModelTable.relations(true); //Use Relations //qbdsPOLModelTable.addLink(fieldNum(POLMobileServiceTable, ModelId), fieldNum(POLModelTable, ModelID)); //Ranges qbdsPOLMobileServiceTable.addRange(fieldNum(POLMobileServiceTable, ModelID)).value(‘Apple’); qbdsPOLMobileServiceTable.joinMode(JoinMode::InnerJoin); //How to run the query – Loop through the select statement […]

Data manipulation commands in Dynamics 365 for Finance and Operations

Data manipulation commands

internal final class POLDataManipulationCommands { /// /// 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. /// /// The specified arguments. public static void main(Args _args) { POLDataManipulationCommands obj = new POLDataManipulationCommands(); obj.whileSelectExample(); } public […]

Containers and its methods in Dynamics 365 for Finance and Operations

Containers and its methods

public void containerClasses() { container con; //Initialize container con = [“Serv001”, 897, 123]; //Insert into container conIns(con, 1, “Serv001”); conIns(con, 2, 1234.80); conIns(con, 3, 123); //Retrieve the value conPeek(con, 1); //Serv001 //Update container conPoke(con, 2, 897); //Serv001, 897, 123 //Delete the value conDel(con, 2, 1); //Serv001, 123 } Copy

Collection classes in Dynamics 365 for Finance and Operations

Collection classes

public void collectionClasses() { //1. List //To add values to the list List lst = new List(Types::String); lst.addEnd(“Value-1”); lst.addEnd(“Value-2”); lst.addStart(“Value-3”); lst.addEnd(“Value-4”); //Ouput: Value-3, Value-1, Value-2, Value-4 //Enumerate the list ListEnumerator lstEnumerator = lst.getEnumerator(); while (lstEnumerator.moveNext()) { info(lstEnumerator.current()); //Current value of the list } //List usage – List of all Devlivered service records POLMobileServiceTable polMobileServiceTable; List […]

Class inheritance in Dynamics 365 for Finance and Operations

Class inheritance

ClassA { public void print() { print “ClassA”; } public void printClassA() { print “ClassA”; } } ClassB extends ClassA { public void print() { print “ClassB”; super(); } public void print(str _printMessage) { print _printMessage; } public void printVal(str _printMessage) { print _printMessage; } public static void main() { ClassB obj = new ClassB(); […]

Clicked event of button control in Dynamics 365 for Finance and Operations

Clicked event of button control

[Form] public class POLInReviewMobileServiceTable extends FormRun { [Control(“Button”)] class UpdateAsRepaired { /// /// /// public void clicked() { super(); //Updation of record. POLMobileServiceTable polServiceTableUpd = POLMobileServiceTable::find(POLMobileServiceTable.ServiceID, true); //assign the values to buffer for updation //update the record ttsbegin; polServiceTableUpd.ServiceStatus = POLServiceStatus::Repaired; polServiceTableUpd.update(); ttscommit; POLMobileServiceTable_ds.research(); info (“Record updated.”); } } } Copy

Usage of args object in forms in Dynamics 365 for Finance and Operations

Usage of args object in forms

internal final class POLUpdateAsDelivered { public static void main(Args _args) { if (_args.record() && _args.record().TableId == tableNum(POLMobileServiceTable)) { POLMobileServiceTable polServiceTable = _args.record(); //Current selected record from the grid. POLMobileServiceTable polServiceTableUpd = POLMobileServiceTable::find(polServiceTable.ServiceID, true); //assign the values to buffer for updation //update the record ttsbegin; polServiceTableUpd.ServiceStatus = POLServiceStatus::Delivered; polServiceTableUpd.update(); ttscommit; FormDataSource fds = _args.record().dataSource(); fds.research(true); info […]

Important form methods in Dynamics 365 for Finance and Operations

Important form methods

[Form] public class POLMobileServiceTable extends FormRun { [DataSource] class POLMobileServiceTable { /// /// /// public void executeQuery() { //Before the query executes //(select * from POLMobileServiceTable where ServiceStatus = InReview this.query().dataSourceTable(tableNum(POLMobileServiceTable)).addRange( fieldNum(POLMobileServiceTable, ServiceStatus)).value(queryValue(POLServiceStatus::InReview)); super(); //Actual query execution (select * from POLMobileServiceTable) //After the query executes } } [DataSource] class POLMobileServiceTable { /// /// /// /// […]

How To Attach a Base64 String To Record Using x++ 

How To Attach a Base64 String To Record Using X++?  Scenario:  When there is a requirement to attach the base64 file content to the record.  High level resolution steps  Detailed resolution steps  Step1: Create an extension class for the “DocuRef” table and add a method with specific parameters  Parameter  Purpose  Common  The Actual table where […]