28. Januar 2015 12:55
Contact.TRANSFERFIELDS(ContactTest);
Contact.VALIDATE("E-Mail",ContactTest."E-Mail");
IF ContactTest."Customer No."<>'' THEN
IF Customer.GET(ContactTest."Customer No.") THEN BEGIN
Contact."Customer Group" := Customer."Customer Group";
"Contact BR"."Contact No." := Contact."No.";
"Contact BR"."Business Relation Code" := 'DEB';
"Contact BR"."Link to Table" := "Contact BR"."Link to Table"::Customer;
"Contact BR"."No." := ContactTest."Customer No.";
"Contact BR".INSERT;
END;
IF ContactTest.Type = ContactTest.Type::Company THEN
Contact."Company No." := ContactTest."No."
ELSE
Contact.VALIDATE("Company No.",ContactTest."Company No.");
Contact.INSERT;
IF "Company No." = xRec."Company No." THEN
EXIT;
TESTFIELD(Type,Type::Person);
SegLine.SETCURRENTKEY("Contact No.");
SegLine.SETRANGE("Contact No.","No.");
IF SegLine.FINDFIRST THEN
ERROR(Text012,FIELDCAPTION("Company No."));
IF Cont.GET("Company No.") THEN
InheritCompanyToPersonData(Cont,xRec."Company No." = '')
ELSE
CLEAR("Company Name");
IF Cont.GET("No.") THEN BEGIN
IF xRec."Company No." <> '' THEN BEGIN
Opp.SETCURRENTKEY("Contact Company No.","Contact No.");
Opp.SETRANGE("Contact Company No.",xRec."Company No.");
Opp.SETRANGE("Contact No.","No.");
Opp.MODIFYALL("Contact No.",xRec."Company No.");
OppEntry.SETCURRENTKEY("Contact Company No.","Contact No.");
OppEntry.SETRANGE("Contact Company No.",xRec."Company No.");
OppEntry.SETRANGE("Contact No.","No.");
OppEntry.MODIFYALL("Contact No.",xRec."Company No.");
Todo.SETCURRENTKEY("Contact Company No.","Contact No.");
Todo.SETRANGE("Contact Company No.",xRec."Company No.");
Todo.SETRANGE("Contact No.","No.");
Todo.MODIFYALL("Contact No.",xRec."Company No.");
InteractLogEntry.SETCURRENTKEY("Contact Company No.","Contact No.");
InteractLogEntry.SETRANGE("Contact Company No.",xRec."Company No.");
InteractLogEntry.SETRANGE("Contact No.","No.");
InteractLogEntry.MODIFYALL("Contact No.",xRec."Company No.");
ContBusRel.RESET;
ContBusRel.SETCURRENTKEY("Link to Table","No.");
ContBusRel.SETRANGE("Link to Table",ContBusRel."Link to Table"::Customer);
ContBusRel.SETRANGE("Contact No.",xRec."Company No.");
SalesHeader.SETCURRENTKEY("Sell-to Customer No.","External Document No.");
SalesHeader.SETRANGE("Sell-to Contact No.","No.");
IF ContBusRel.FINDFIRST THEN
SalesHeader.SETRANGE("Sell-to Customer No.",ContBusRel."No.")
ELSE
SalesHeader.SETRANGE("Sell-to Customer No.",'');
IF SalesHeader.FIND('-') THEN
REPEAT
SalesHeader."Sell-to Contact No." := xRec."Company No.";
IF SalesHeader."Sell-to Contact No." = SalesHeader."Bill-to Contact No." THEN
SalesHeader."Bill-to Contact No." := xRec."Company No.";
SalesHeader.MODIFY;
UNTIL SalesHeader.NEXT = 0;
SalesHeader.RESET;
SalesHeader.SETCURRENTKEY("Bill-to Contact No.");
SalesHeader.SETRANGE("Bill-to Contact No.","No.");
SalesHeader.MODIFYALL("Bill-to Contact No.",xRec."Company No.");
END ELSE BEGIN
Opp.SETCURRENTKEY("Contact Company No.","Contact No.");
Opp.SETRANGE("Contact Company No.",'');
Opp.SETRANGE("Contact No.","No.");
Opp.MODIFYALL("Contact Company No.","Company No.");
OppEntry.SETCURRENTKEY("Contact Company No.","Contact No.");
OppEntry.SETRANGE("Contact Company No.",'');
OppEntry.SETRANGE("Contact No.","No.");
OppEntry.MODIFYALL("Contact Company No.","Company No.");
Todo.SETCURRENTKEY("Contact Company No.","Contact No.");
Todo.SETRANGE("Contact Company No.",'');
Todo.SETRANGE("Contact No.","No.");
Todo.MODIFYALL("Contact Company No.","Company No.");
InteractLogEntry.SETCURRENTKEY("Contact Company No.","Contact No.");
InteractLogEntry.SETRANGE("Contact Company No.",'');
InteractLogEntry.SETRANGE("Contact No.","No.");
InteractLogEntry.MODIFYALL("Contact Company No.","Company No.");
END;
IF CurrFieldNo <> 0 THEN
MODIFY;
END;
28. Januar 2015 13:11
Rally Vincent hat geschrieben:Und dadurch sollte eigentlich der Trigger bei Company No. durchlaufen werden, sodass die Company Name eingesetzt wird.
Contact.INSERT;
Contact.INSERT(TRUE);
RMSetup.GET;
IF "No." = '' THEN BEGIN
RMSetup.TESTFIELD("Contact Nos.");
NoSeriesMgt.InitSeries(RMSetup."Contact Nos.",xRec."No. Series",0D,"No.","No. Series");
END;
IF NOT SkipDefaults THEN BEGIN
IF "Salesperson Code" = '' THEN
"Salesperson Code" := RMSetup."Default Salesperson Code";
IF "Territory Code" = '' THEN
"Territory Code" := RMSetup."Default Territory Code";
IF "Country/Region Code" = '' THEN
"Country/Region Code" := RMSetup."Default Country/Region Code";
IF "Language Code" = '' THEN
"Language Code" := RMSetup."Default Language Code";
IF "Correspondence Type" = "Correspondence Type"::" " THEN
"Correspondence Type" := RMSetup."Default Correspondence Type";
IF "Salutation Code" = '' THEN
IF Type = Type::Company THEN
"Salutation Code" := RMSetup."Def. Company Salutation Code"
ELSE
"Salutation Code" := RMSetup."Default Person Salutation Code";
END;
TypeChange; // hier wird erst der Company Name gesetzt
"Last Date Modified" := TODAY;
"Last Time Modified" := TIME;
28. Januar 2015 18:01
IF ContactTest.Type = ContactTest.Type::Company THEN BEGIN
Contact."Company No." := ContactTest."No.";
Contact."Company Name" := ContactTest.Name
END ELSE BEGIN
IF Contact2.GET("Company No.") THEN
Contact."Company Name" := Contact2.Name;