Reputation: 1021
I try to add contacts to a customer, like this:
WHILE (LoopCount <> 0) DO
BEGIN
KlantContact.GET(FirstContact);
KlantContact.VALIDATE(KlantContact."Company No.", BussinesContactName."Contact No."); //'44241';
KlantContact.MODIFY;
MESSAGE(KlantContact.Name);
LoopCount := LoopCount - 1;
FirstContact := INCSTR(FirstContact);
END;
But the problem is that the contacts are not connected with the customer.
Upvotes: 1
Views: 148
Reputation: 1887
If you look in the OnInsert
trigger of the Customer Table you can see, that a Method UpdateContFromCust.OnInsert(Rec);
is called. Within this Method a new Contact Bus. Relation is inserted.
From Method InsertNewContact (Codeunit 5056), with Cont
beeing the contact and RMSetup
beeing Marketing Setup
WITH ContBusRel DO BEGIN
INIT;
"Contact No." := Cont."No.";
"Business Relation Code" := RMSetup."Bus. Rel. Code for Customers";
"Link to Table" := "Link to Table"::Customer;
"No." := Cust."No.";
INSERT(TRUE);
END;
Upvotes: 2
Reputation: 705
You have to use the Contact Business Relation table to link them together. Just check the table structure.
Otherwise, if you set up the Bus. Relation Codes in the Marketing Setup NAV will create a new Contact in the background for Customers, Vendors and Bank Accounts.
Upvotes: 3