Service in SysOperation framework in D365 F&O

X++ Programming Language >   D365 Forms >   SysOperation framework  

Long Question

240


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.


This Particular section is dedicated to Question & Answer only. If you want learn more about X++ Programming Language. Then you can visit below links to get more depth on this subject.




Join Our telegram group to ask Questions

Click below button to join our groups.