Customer - Contact relation.

FunkygrazFunkygraz Member Posts: 12
On the customer card form (ID 21), if you assist in the primary contact field a form pops up listing the customers contacts. I need to show this list in a sub form on the customer card.

I figured i would make a sub form based on the Contact list and filter by the Company No. field. Untill i found out that the Company No. field (5051) in the contact table is referring to other contacts.

From the customer card i ended up in the contact business relations table. Is this where i should be looking? And, any tips to make it all link ( I tried looking at the customer card form's design to no avail )

I'm running Nav 5.0.


P.S: I'm new to Nav development so if there's any more info u need let me know

[Edit]

Just looking at the customer table C/AL code and i found:
ContBusRel.SETCURRENTKEY("Link to Table","No.");
ContBusRel.SETRANGE("Link to Table",ContBusRel."Link to Table"::Customer);
ContBusRel.SETRANGE("No.","No.");
IF ContBusRel.FIND('-') THEN
  Cont.SETRANGE("Company No.",ContBusRel."Contact No.");

IF "Primary Contact No." <> '' THEN
  IF Cont.GET("Primary Contact No.") THEN ;
IF FORM.RUNMODAL(0,Cont) = ACTION::LookupOK THEN
  VALIDATE("Primary Contact No.",Cont."No.");

Ill try to find the way|place to work / copy it now ^^

P.S.S: My first post gets a MUID of ANUB, go figure

Answers

  • FunkygrazFunkygraz Member Posts: 12
    Ive been trying to apply the code from the customer table to my form with no succes, anyone have any idea where i can find info on how to do this or can show me how to rework the code?

    Thanks in advance

    [EDIT]

    My main form now has:
    ContBusRel.SETCURRENTKEY("Link to Table","No.");
    ContBusRel.SETRANGE("Link to Table",ContBusRel."Link to Table"::Customer);
    ContBusRel.SETRANGE("No.","No.");
    IF ContBusRel.FIND('-') THEN
        CurrForm.ContactListSubform.FORM.SetCustomerFilter(ContBusRel."Contact No.");
    
    

    and on the subform the function looks like:
    SetCustomerFilter(Code CustFilter)
    SETFILTER("Company No.",CustFilter);
    CurrForm.UPDATE(FALSE);
    
    

    And it works, thanks for the feedback ^^
  • navuser1navuser1 Member Posts: 1,329
    Hi Funkygraz,

    Create a Function on the Subform(subform name :navuser1)
    Function name :- SetSubformLines
    Local Parameter name : lCont (Code 100)
    CAL code of Function :

    SETRANGE("Company No.",lCont);
    CurrForm.UPDATE(FALSE);

    After that Go to the Function Name: OnOpen of the Customer Card (ID 21) and put the code

    ContBusRel.SETCURRENTKEY("Link to Table","No.");
    ContBusRel.SETRANGE("Link to Table",ContBusRel."Link to Table"::Customer);
    ContBusRel.SETRANGE("No.","No.");
    IF ContBusRel.FIND('-') THEN
    CurrForm.navuser.FORM.SetSubformLines(ContBusRel."Contact No.");


    Do the same after the Function OnAfterGetRecord of the Customer card (ID 21);

    I think this will work.
    Now or Never
Sign In or Register to comment.