Hi guys, Today we see how to Get caller record in Sys operation Controller class in AX7/D365 fo.
Check the below class:
[SysOperationJournaledParametersAttribute(true)]
class DaxPriceDiscController extends SysOperationServiceController
{
Common callerRecord;
DAXPriceDiscDataContract daxPriceDiscContract;
PriceDiscAdmTable priceDiscAdmTable;
PriceDiscAdmTrans priceDiscAdmTrans;
public Common parmCallerRecord(Common _callerRecord = callerRecord)
{
callerRecord = _callerRecord;
return callerRecord;
}
private void initFromCaller()
{
daxPriceDiscContract = this.getDataContractObject();
switch (this.parmCallerRecord().TableId)
{
case tableNum(PriceDiscAdmTrans) :
priceDiscAdmTrans = this.parmCallerRecord() as PriceDiscAdmTrans;
daxPriceDiscContract.parmPriceDiscJournalNum(priceDiscAdmTrans.journalnum);
break;
}
}
public static DaxPriceDisccontroller newFromArgs(Args _args)
{
IdentifierName className;
IdentifierName methodName;
SysOperationExecutionMode executionMode;
DaxPriceDisccontroller controller;
[className, methodName, executionMode] = SysOperationServiceController::parseServiceInfo(_args);
if (_args.record())
{
executionMode = SysOperationExecutionMode::Synchronous;
}
controller = new DaxPriceDisccontroller(className, methodName, executionMode);
controller.parmArgs(_args);
controller.parmCallerRecord(_args.record());
return controller;
}
protected void refreshCallerRecord()
{
FormDataSource callerDataSource;
if (this.parmCallerRecord() && this.parmCallerRecord().dataSource())
{
callerDataSource = this.parmCallerRecord().dataSource();
callerDataSource.research(true);
}
}
void new(IdentifierName _className = classStr(DaxPriceDiscService),
IdentifierName _methodName = methodStr(DaxPriceDiscService, insertLines),
SysOperationExecutionMode _executionMode = SysOperationExecutionMode::Synchronous)
{
super(_className, _methodName, _executionMode);
this.parmClassName(classStr(DaxPriceDiscService));
this.parmMethodName(methodStr(DaxPriceDiscService, insertLines));
}
Public static void Main(Args _args)
{
DaxPriceDiscController daxPriceDiscController= new DaxPriceDiscController();
daxPriceDiscController = DaxPriceDiscController::newFromArgs(_args);
daxPriceDiscController.initFromCaller();
daxPriceDiscController.refreshCallerRecord();
daxPriceDiscController.startOperation();
}
public DAXPriceDiscDataContract parmDaxPriceDiscContract(DAXPriceDiscDataContract _daxPriceDiscContract = daxPriceDiscContract)
{
daxPriceDiscContract = _daxPriceDiscContract;
return daxPriceDiscContract;
}
}
Keep Daxing!!
No comments:
Post a Comment