Greetings,
I am trying to add a synchronization recurring job for a custom integration mapping I created.
However, I do not see where I am suposed to define which integration it is synching. When I look at the default jobs in the queue, none indicate which integration it is running.
Mine simply give this error:
A RecordID from table '' cannot be used with a record from table 'Integration Table Mapping'. |
Any idea what I am doing wrong?
Cheers
Hi,
As you can see from the date, this is from a long time ago. But maybe one of those points can help. Those are exctract from my entire sync file. This is of course not the best way to do it, but its the way I did it couple of years ago, and no issues till now.
[EventSubscriber(ObjectType::Codeunit, Codeunit::"Integration Management", 'OnIsIntegrationRecord', '', true, true)] local procedure HandleOnIsIntegrationRecord(TableID: Integer; var isIntegrationRecord: Boolean) begin if TableID = DATABASE::MyCustomTable then isIntegrationRecord := true; end; local procedure InsertIntegrationTableMapping(var IntegrationTableMapping: Record "Integration Table Mapping"; MappingName: Code[20]; TableNo: Integer; IntegrationTableNo: Integer; IntegrationTableUIDFieldNo: Integer; IntegrationTableModifiedFieldNo: Integer; TableConfigTemplateCode: Code[10]; IntegrationTableConfigTemplateCode: Code[10]; SynchOnlyCoupledRecords: Boolean) begin IntegrationTableMapping.CreateRecord(MappingName, TableNo, IntegrationTableNo, IntegrationTableUIDFieldNo, IntegrationTableModifiedFieldNo, TableConfigTemplateCode, IntegrationTableConfigTemplateCode, SynchOnlyCoupledRecords, IntegrationTableMapping.Direction::FromIntegrationTable, 'CDS'); end; [EventSubscriber(ObjectType::Codeunit, Codeunit::"CDS Setup Defaults", 'OnBeforeResetConfiguration', '', true, true)] local procedure HandleOnOnBeforeResetConfiguration(CDSConnectionSetup: Record "CDS Connection Setup"; var IsHandled: Boolean) var CDSCustom: Record "CDS cre123_MyCustomTable"; //cds table CustomTable: Record MyCustomTable; //bc table IntegrationFieldMapping: Record "Integration Field Mapping"; IntegrationTableMapping: Record "Integration Table Mapping"; begin InsertIntegrationTableMapping( IntegrationTableMapping, 'CUSTOMTABLE1', DATABASE::MyCustomTable, DATABASE::"CDS cre123_MyCustomTable", CDSCustom.FieldNo(cre123_CustomId), CDSCustom.FieldNo(ModifiedOn), '', '', false); IntegrationTableMapping.Modify(); globalParam.get('CREATEJOBS'); if (globalParam.TextWaarde = 'TRUE') then RecreateJobQueueEntryFromIntTableMapping(IntegrationTableMapping, 30, true, 30, 'CRM CDS CustomTable'); InsertIntegrationFieldMapping('CUSTOMTABLE1', CustomTable.FieldNo(cr123_CUSTOM1), CDSCustom.FieldNo(cr123_CUSTOM1), IntegrationFieldMapping.Direction::FromIntegrationTable, '', true, false); InsertIntegrationFieldMapping('CUSTOMTABLE1', CustomTable.FieldNo(cr123_CUSTOM2), CDSCustom.FieldNo(cr123_CUSTOM2), IntegrationFieldMapping.Direction::FromIntegrationTable, '', true, false); IsHandled := true; end; procedure InsertIntegrationFieldMapping(IntegrationTableMappingName: Code[20]; TableFieldNo: Integer; IntegrationTableFieldNo: Integer; SynchDirection: Option; ConstValue: Text; ValidateField: Boolean; ValidateIntegrationTableField: Boolean) var IntegrationFieldMapping: Record "Integration Field Mapping"; begin IntegrationFieldMapping.CreateRecord(IntegrationTableMappingName, TableFieldNo, IntegrationTableFieldNo, SynchDirection, ConstValue, ValidateField, ValidateIntegrationTableField); end; local procedure GetTableFilterFromView(TableID: Integer; Caption: Text; View: Text): Text var FilterBuilder: FilterPageBuilder; begin FilterBuilder.AddTable(Caption, TableID); FilterBuilder.SetView(Caption, View); exit(FilterBuilder.GetView(Caption, false)); end; local procedure RecreateJobQueueEntryFromIntTableMapping(IntegrationTableMapping: Record "Integration Table Mapping"; IntervalInMinutes: Integer; ShouldRecreateJobQueueEntry: Boolean; InactivityTimeoutPeriod: Integer; ServiceName: Text) var JobQueueEntry: Record "Job Queue Entry"; begin 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", IntegrationTableMapping.RecordId()); JobQueueEntry.DeleteTasks(); JobQueueEntry.InitRecurringJob(IntervalInMinutes); 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" := IntegrationTableMapping.RecordId(); JobQueueEntry."Run in User Session" := false; JobQueueEntry.Description := CopyStr(StrSubstNo(JobQueueEntryNameTok, IntegrationTableMapping.Name, ServiceName), 1, MaxStrLen(JobQueueEntry.Description)); JobQueueEntry."Maximum No. of Attempts to Run" := 10; JobQueueEntry.Status := JobQueueEntry.Status::Ready; JobQueueEntry."Rerun Delay (sec.)" := 30; JobQueueEntry."Inactivity Timeout Period" := InactivityTimeoutPeriod; if ShouldRecreateJobQueueEntry then Codeunit.Run(Codeunit::"Job Queue - Enqueue", JobQueueEntry) else JobQueueEntry.Insert(true); end;
Hi,
Sorry to jump on this ticket, I'm encountering the same error when running the standard Customer - Common Data Service Synchronization Job in BC Saas 19.4 GB
What exactly did you do to resolve your own issue?
Any help would be greatly apprecaited.
Hi,
I found what i needed in the recreate job internal procedure. Thank you.
Cheers
Hi,
Ah yes, I did miss the custom integration part in your posting. What you want is discussed here:
docs.microsoft.com/.../walkthrough--customizing-microsoft-dynamics-crm-integration-in-dynamics-nav
Under Tip:
If you want to learn how to schedule the synchronization by using a job queue entry, examine the code on the RecreateJobQueueEntry function in codeunit 5330 CRM Integration Management and see how it is called by the integration code for other Microsoft Dynamics 365 for Sales entities in the codeunit.
Thanks.
Hi Marco,
I am sorry, that was not the question.
The question is how do you add a NEW scheduler, not edit an existing one.
Adding a new scheduler using that option, gives the error mentioned in my first post.
Hello,
From here you can define the schedule:
Thanks.
Stay up to date on forum activity by subscribing. You can also customize your in-app and email Notification settings across all subscriptions.
André Arnaud de Cal... 290,902 Super User 2024 Season 2
Martin Dráb 229,302 Most Valuable Professional
nmaenpaa 101,156