//---get the IntegrationTable Mapping record with the name. if the record is found create the Job queue entry
TableMappingRec."Name" := 'VENDOR-VENDOR';
if TableMappingRec.Find('=') then begin
Message('About to create Job Queue entry for ' + TableMappingRec.Name);
procedure CreateCustomSyncJobQueueEntry(TableMappingRec: Record "Integration Table Mapping")
JobQueueEntry: Record "Job Queue Entry";
JobQueueEntry.SetRange("Object Type to Run", JobQueueEntry."Object Type to Run"::Codeunit);
JobQueueEntry.SetRange("Object ID to Run", Codeunit::"Integration Synch. Job Runner");
JobQueueEntry.SetRange("Record ID to Process", TableMappingRec.RecordId());
JobQueueEntry."Object Type to Run" := JobQueueEntry."Object Type to Run"::Codeunit;
JobQueueEntry."Object ID to Run" := Codeunit::"Integration Synch. Job Runner";
JobQueueEntry."Record ID to Process" := TableMappingRec.RecordId();
JobQueueEntry."Run in User Session" := false;
JobQueueEntry.Description := 'VENDOR-VENDOR - Custom Sync Job';
JobQueueEntry."Maximum No. of Attempts to Run" := 10;
JobQueueEntry.Status := JobQueueEntry.Status::Ready;
JobQueueEntry."Rerun Delay (sec.)" := 30;
JobQueueEntry."Inactivity Timeout Period" := 5;
JobQueueEntry."Recurring Job" := true;
With the above code, I managed to create job queue entry for the custom table. Not sure if this the appropriate way to create but it has resolved the issue.
There is a standard function on the “CRM Setup Defaults” table named “CreateJobQueueEntry”. You only need to call this with your Integration Table Mapping record and it will create it for you. This should be set when you create the record via the events for the default setup.
Thanks Jon for your response. As I use it directly as you have suggested, I am getting the following message while running the Default Sync setup and the job entry not getting created. That was the reason, I recreated the method and call it to create the job queue entry and it works fine.
The following AL methods are limited during write transactions because one or more tables will be locked: Form.RunModal is not allowed in write transactions. Codeunit.Run is allowed in write transactions only if the return value is not used. For example, ‘OK := Codeunit.Run()’ is not allowed. Report.RunModal is allowed in write transactions only if ‘RequestForm = false’. For example, ‘Report.RunModal(…,false)’ is allowed. XmlPort.RunModal is allowed in write transactions only if ‘RequestForm = false’. For example, ‘XmlPort.RunModal(…,false)’ is allowed. Use the commit method to save the changes before this call, or structure the code differently. Contact your application developer for further assistance.