Create a Batch Job D365 FnO : Step 2

DataContract Class


Step 1 : Create DEMOSalesTableContract and add the attribute DataContractAttribute to the class.

 [DataContractAttribute]  
 class DEMOSalesTableContract  
 {  
 }  


Step 2 : Lets add Data Members to this contract by first declaring them in the class declaration.

 [DataContractAttribute]  
 class DEMOSalesTableContract  
 {  
    str packedQuery;  
    boolean demoValue;
} 


Step 3 : This is just a simple string field, nothing special here except for the DataMemberAttribute attribute that indicates that this method is a data member inputting the Sales order number.

 [DataMemberAttribute]   
  public boolean parmDemoValue(SalesIdBase _demoValue = demoValue)   
  {   
   demoValue= _demoValue;   
   return demoValue;   
  }   




For more customization in parameters attribute, click here.


Step 4 : We will also add a query, so we can loop all SalesTable records. As you can see, we can specify the query by using the AifQueryTypeAttribute. The query DEMOSalesTable is just a query in the AOT with SalesTable as a datasource.

 [DataMemberAttribute,  
   AifQueryTypeAttribute('_packedQuery', querystr(DEMOSalesTable))  
 ]  
 public str parmQuery(str _packedQuery = packedQuery)  
 {  
   packedQuery = _packedQuery;  
   return packedQuery;  
 }  


Step 5 : Next, we add two helper methods that are not Data Members, so we can easily set and get the query variable.

To get the query :
 public Query getQuery()  
 {  
   return new Query(SysOperationHelper::base64Decode(packedQuery));  
 }  

To set the query :
 public void setQuery(Query _query)  
 {  
   packedQuery = SysOperationHelper::base64Encode(_query.pack());  
 }  









Comments