Access denied: SysOperationServiceController in D365FO

HI All,

We could able to schedule a SysOperationServiceController class in batch through x++ code, but we getting an error while executing. 

Error msg: Access denied: XXXXController

Scheduling class:

objBatchheader = Batchheader::construct();
objBatchSchedule = new sysDictClass(XXXClassId);
object = objBatchSchedule.makeObject();
objBatchInfo = object.batchInfo();
objBatchInfo.parmRetriesOnFailure(noOfRetriesOnFailure);
objBatchInfo.parmCaption(""); // Description Batch Job
objBatchInfo.parmGroupId(''); // Batch Gorup
objBatchInfo.parmDataareaId(dataArea.dataAreaId);
objBatchInfo.parmBatchExecute(NoYes::Yes);
objBatchheader.addTask(object);

// Set the recurrence data
sysRecurrenceData = SysRecurrence::defaultRecurrence();
sysRecurrenceData = SysRecurrence::setRecurrenceEndAfter(sysRecurrenceData, 1);
SysRecurrence::setRecurrenceStartDateTime(sysRecurrenceData, DateTimeUtil::addSeconds(DateTimeUtil::utcNow(), 20)); // Set range of recurrence
SysRecurrence::setRecurrenceUnit(sysRecurrenceData, SysRecurrenceUnit::Minute,1); // Set reccurence pattern
objBatchheader.parmRecurrenceData(sysRecurrenceData);
objBatchheader.parmAlerts(NoYes::No, NoYes::Yes, NoYes::No, NoYes::Yes, NoYes::Yes);
objBatchheader.save();

Controller Class:

class XXXXController extends SysOperationServiceController
{
public static void main(Args _args)
{
XXXXController controller = new XXXXController(classStr(XXXXService), methodStr(XXXXService,runService), SysOperationExecutionMode::Synchronous);

controller.parmLoadFromSysLastValue(false);
controller.batchInfo().parmBatchExecute(NoYes::Yes);
controller.startOperation();
}

}

Note: There is no issue when we schedule a RunbaseBatch class. 

Are we missing anything...

Parents Reply Children
No Data
Related
Recommended