Tuesday, December 26, 2023

Sys Operation Framework in D-365 ??


Sys Operation Framework in D-365 ??


First, what are some scenarios where you might want a process or job to run in the background?

The most common scenario is that you have a set of records that you need to process or do some calculation for. Perhaps you have used a Data Entity or Service to bring data into a staging table. Now you need to loop through each record and create functional data inside the system. SysOperation Framework in D365 is made for just this sort of thing.

Another scenario is that you have some process that you normally run on a single record in a form, but now you want to run the process on many records. SysOperation Framework in D365 can easily be setup to loop through a group of records and call existing code to process each record.

Lastly, is a scenario that is often under used. You may have a button on a form that when clicked will run some process on a record. If that process does not run instantly and you do not need to immediately use the result of the process, you can offload that work to job that uses SysOperation Framework in D365. Perhaps running a single process only takes 15 seconds to run, but by letting the system do the work in the background you can improve the user experience greatly. Typically a user would have to wait those 15 seconds while the operation completes. But now they are given back control immediately and can continue working.

Create The Contract

The contract class defines the parameters that will be passed to the service class for processing. In this example, let's assume we want to update customer group.

[DataContract]

Public class  WRE_SCPCustGroupChangeContract  extends SysOperationDataContractBase

{

       CustAccount     custNum;

       CustGroupId     custGroup;

   [DataMember]

     public CustAccount custNum(CustAccount _custNum = custNum)

       {

          custNum = _custNum;

           return custNum;

       }

   [DataMember]

    public CustGroupId custGroup(CustGroupId _custGroup = custGroup)

       {

           custGroup = _custGroup;

            return custGroup;

       }


}


 Service Class :

The service class contains the business logic for processing the batch operation.


public class WRE_SCPCustGroupChange

{

   CustAccount custNum;

   CustGroupId custGroup;

   protected void InitFromContract(WRE_SCPCustGroupChangeContract  _contract)

   {

      custNum = _contract.custNum();

      custGroup = _contract.custGroup();

   }

   protected void UpdateCustGroup()

   {

       CustTable cust = CustTable::Find(custNum, true);

       if (cust.RecId != 0)

       {

           cust.CustGroup = custGroup; cust.update();


       }


   }


   public void Run( WRE_SCPCustGroupChangeContract _contract)

   {

       this.InitFromContract(  _contract);

       ttsbegin;

       this.UpdateCustGroup();

       ttscommit;


   }

}

Create Controller class:

The controller class is responsible for initiating the batch operation by creating an instance of the service class and passing the contract parameters.


public  class WRE_SCPCustGroupChangeController extends SysOperationServiceController

{

   public static void main(Args _args)

   {

       WRE_SCPCustGroupChangeController controller;

       controller = new WRE_SCPCustGroupChangeController(classStr(WRE_SCPCustGroupChange),methodStr(WRE_SCPCustGroupChange, Run),

         SysOperationExecutionMode::Synchronous);

       controller.parmDialogCaption("Change Customer Group");

       controller.startOperation();

   }


}


Create new Action Menu iteam  






Open Account Receivable 


look at customer Group Number Required  to  change the 90 -to -10 



Open the Account Receivable Action Menu I team open look at above page parameters like that customer group 90 to change -10 customer account like same click OK



Open customer id -DE-001 - customer group-10 changes Done 
    

 





No comments:

Post a Comment

How To Create A WorkFlow In D365F&O

  How To Create Work Flow In D-365 F&O ? What is workflow? A workflow in the dynamics 365 apps is a way that automate business processes...