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
  • Please use Insert > Insert Code to paste source; it'll be much easier to read.

    Also, your code isn't complete. Most importantly, what's the type of 'object' variable?

    I think the primary problem is in the fact that you specify the method to be called (runService()) in main() method only, but this method won't be called at all. Therefore you effectively don't tell the framework which method it should call. You can fix this problem by overriding new() method of XXXXController and defining it there.

Reply Children
Related
Recommended