Service in SysOperation framework in D365 F&O

Long Answer
Views 170

Answer:

Service in SysOperation framework in D365 F&O

Service: As I mentioned earlier, it's not a good practice to keep the whole business logic in one controller class, because it would be a big responsibility for a single class to handle. That's why, here, we have created a Service class which is referenced in the Controller class.

In the VS project , create a new class called CustBalanceController with the following code snippet:


 class CustBalanceService 
 {   
           [SysEntryPointAttribute] 
            public void processData(CustBalanceDataContract _custBalanceDataContract) 
            { 
               QueryRun    queryRun; 
               CustTable   custTable; 
               Amount      balance; 
               ; 
    
               // create a new queryrun object 
               queryRun = new queryRun 
               (_custBalanceDataContract.getQuery()); 
 
               // loop all results from the query 
               while(queryRun.next()) 
              {   
                 custTable = queryRun.get(tableNum(custTable)); 
 
                 if(_custBalanceDataContract.parmTransDate()) 
                 balance =  custTable.balanceMST
                  (dateNull(),
                   _custBalanceDataContract.parmTransDate()); 
               else 
                  balance = custTable.balanceMST(); 
                  // display the balance 
                  info(strFmt("%1 - %2",custTable.AccountNum,balance)); 
     } 
   } 
 } 

Here, we get the contract parameters and execute the business logic. The customer balance in the accounting currency is displayed as at a date if a certain date is specified. Herein, we could also multithread our process.

Related Articles:

This section is dedicated exclusively to Questions & Answers. For an in-depth exploration of X++ Programming Language, click the links and dive deeper into this subject.

Join Our telegram group to ask Questions

Click below button to join our groups.