How to update field in contact when i create customer

enoahmedspahicenoahmedspahic Member Posts: 25
Hi!This is my first topic and my english is not good!So...help if you know how!

I have expended Contact form with some basic informations about customer (I can create customer here).I can pick template for creating customer but when I create them (it is created fine) i don't know how to update Contact table and also Customer fields on Contact form.

Thanks!

Answers

  • kinekine Member Posts: 12,562
    See the OnModify trigger of the Customer table. You will see something like:
    IF (Name <> xRec.Name) OR
       ("Search Name" <> xRec."Search Name") OR
       ("Name 2" <> xRec."Name 2") OR
       (Address <> xRec.Address) OR
       ("Address 2" <> xRec."Address 2") OR
       (City <> xRec.City) OR
       ("Phone No." <> xRec."Phone No.") OR
       ("Telex No." <> xRec."Telex No.") OR
       ("Territory Code" <> xRec."Territory Code") OR
       ("Currency Code" <> xRec."Currency Code") OR
       ("Language Code" <> xRec."Language Code") OR
       ("Salesperson Code" <> xRec."Salesperson Code") OR
       ("Country Code" <> xRec."Country Code") OR
       ("Fax No." <> xRec."Fax No.") OR
       ("Telex Answer Back" <> xRec."Telex Answer Back") OR
       ("VAT Registration No." <> xRec."VAT Registration No.") OR
       ("Registration No." <> xRec."Registration No.") OR
       ("Post Code" <> xRec."Post Code") OR
       (County <> xRec.County) OR
       ("E-Mail" <> xRec."E-Mail") OR
       ("Home Page" <> xRec."Home Page") OR
       (Contact <> xRec.Contact)
    THEN BEGIN
      MODIFY;
      UpdateContFromCust.OnModify(Rec);
    END;
    

    I think that this will help you to find correct point and what you need to do to use standard functionality for syncing the Customer with Contact.
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
  • enoahmedspahicenoahmedspahic Member Posts: 25
    When I click on (something like this) Functions->create as->Customer...It create Customer. I was looking on klick of that MENU ITEM (on Contact form) and it start with creating customer. Function is createCustomer and it is in Contact table.It use selected template for creating Customer.
    I think...after creating Customer I must initiate some synchronisation between Customer and Contact but I don't know how. Is there any function to force synchronisation....because...afther I create Contact and Customer(using template) and ...when I change some properti on Customer it modify coresponding property on Contact and vice versa. :roll:
    Thanks again.
  • kinekine Member Posts: 12,562
    Look at my example I posted. Read It. Try to understand it. It is what you are searching fore. THis is the code, which sync the Customer with the contact each time you change something on the customer...
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
  • enoahmedspahicenoahmedspahic Member Posts: 25
    edited 2008-07-28
    Thanks for help.I ame close to finish this.I put in Contact table , in function CreateCustomer(CustomerTemplate:Code [10]) this code
    ....

    IF( Cust.MODIFY)THEN BEGIN
    UpdateContFromCust.OnModify(Cust);
    ....
    Synchronization work fine fot two fields(it syinchronise them). For :

    Cont."Cust. Gen. Bus. Posting Group", and Cont."Customer Posting Group".

    In Code unit CustCont-Update is folowing code (OnModify):
    ....
    Cont."Cust. Gen. Bus. Posting Group":=Cust."Gen. Bus. Posting Group";
    Cont."Cust. VAT Bus. Posting Group":=Cust."VAT Bus. Posting Group";
    Cont."Customer Posting Group":=Cust."Customer Posting Group";
    ....

    I don't know wher is trick.
  • enoahmedspahicenoahmedspahic Member Posts: 25
    I appreciate any help!
  • kinekine Member Posts: 12,562
    Thanks for help.I ame close to finish this.I put in Contact table , in function CreateCustomer(CustomerTemplate:Code [10]) this code
    ....

    IF( Cust.MODIFY)THEN BEGIN
    UpdateContFromCust.OnModify(Cust);
    ....
    Synchronization work fine fot two fields(it syinchronise them). For :

    Cont."Cust. Gen. Bus. Posting Group", and Cont."Customer Posting Group".

    In Code unit CustCont-Update is folowing code (OnModify):
    ....
    Cont."Cust. Gen. Bus. Posting Group":=Cust."Gen. Bus. Posting Group";
    Cont."Cust. VAT Bus. Posting Group":=Cust."VAT Bus. Posting Group";
    Cont."Customer Posting Group":=Cust."Customer Posting Group";
    ....

    I don't know wher is trick.

    I do not understand your problem. You need to add your own code there which will copy your new fields from customer to contact. This code is doing it for standard fields. You need to expand it with your own code.
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
  • enoahmedspahicenoahmedspahic Member Posts: 25
    I have expended Contact table with these added fields:
    Cont."Cust. Gen. Bus. Posting Group",
    Cont."Customer Posting Group",
    and they are related to same fields in Customer. When I create Customer from Contact with manual inserting values in that fields in form it create customer fine. In that case all synchronization work fine. Other case is when I create Customer from Contact using template.I resolve that problem with previous Code but it doesn't work for all extended fields. It work only for :
    Cont."Cust. Gen. Bus. Posting Group" and Cont."Customer Posting Group".
    Field "Cust.Vat .Bus. Posting group" is empty afther creating Customer using template, even synchronization work for other fields.
    I will try to to fix that. Thanks!
  • enoahmedspahicenoahmedspahic Member Posts: 25
    I find mistake(human error!). I forget one line in function wich create Customer using template.
    Thanks KINE!
  • kinekine Member Posts: 12,562
    You are welcome... 8)
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
  • garakgarak Member Posts: 3,263
    Please write [solved] in your subject, if your problem is finished.

    Regard
    Do you make it right, it works too!
  • enoahmedspahicenoahmedspahic Member Posts: 25
    I can't find where!?Can you explain?
  • santoshmkcetsantoshmkcet Member Posts: 229
    it is in the 27th line my friend!!!

    it is self explanatory!!!!
    Thanks & Regards
    Santosh
    Where Stones can be transformed to Gold
  • enoahmedspahicenoahmedspahic Member Posts: 25
    My qvestion vas:"Has this forum some procedure for that or...?",but I find way.....
  • santoshmkcetsantoshmkcet Member Posts: 229
    every problem has its own funda of solutionizing for getting thte result is what makes the problem possible to solve!!!!
    Thanks & Regards
    Santosh
    Where Stones can be transformed to Gold
Sign In or Register to comment.