Easy Navision programing Question??

Mitch_RolskyMitch_Rolsky Member Posts: 7
edited 2000-02-01 in Navision Financials
I have a field in the job table that is related to a field in another table. When the user drills down and selects a record from the related table the related field is returned to the job table. The problem is that the related table has a primary key with three varables. I want two other fields in the job table to be also be populated based on the selected record. Filtering will not work because of the multple keys. Likewise a "get" statement won't work for the same reason. And, the related table is not initialized or retreived by the drilldown/lookup.

Is there a an easy way to return other varables along with the lookup? I know there must be-- but I can't find anything on this!

Comments

  • TheDoubleHTheDoubleH Member Posts: 67
    On the Field you need to select Property And go to the line TableRelation. There you would see a ... icon (when you are on the right side), Press that, and you are now having the option to select what field from the record, you want to "bring back".

    re. Get, you need to have ALL primary key fields, to use get.

    ie. SalesLine.get(DocType,DocNo,Line);



    Kind Regards

    Henrik Helgesen,
    Navision Solution Developer
    <BLOCKQUOTE><font size="1" face="Verdana, Arial">quote:</font><HR>Great Minds Discuss Ideas,
    Average minds discuss events
    Small minds discuss people (With Malicious Intention)

    Admiral Hyman Rickover, US Navy<HR></BLOCKQUOTE>
    Kind Regards

    Henrik Helgesen,
    President | Helgesen Consulting
    about.me | LinkedIN
  • Mitch_RolskyMitch_Rolsky Member Posts: 7
    Thank you -- I understand that- My problem is that I need to "bring" back multiple fields-- not just one

    I understand that I can't use the "get" because of the multiple fileds that comprise the primary key.

    Likewise, because there is no single unique field, like a line number, I can not set a filter and use the find function-

    I will look again- but are you saying I can specify more than one field to bring back ?
  • Craig_NeedhamCraig_Needham Member Posts: 23
    Greetings.

    I am not sure I understand your problem. If you want to retrieve more than one field from the form that you made a lookup to, the tablerelation way is probably not your solution. Look at onlookup trigger with GETRECORD Function. See below for more details.

    If I am correct you want to lookup from a field on (for example) the job card. Then select a record from a list that appears. Once selected Three of those fields need to populate three fields on the job card.

    I don't know of an easy/Quick (relative) way to do this. However, If you use the lookup trigger on the field and handle the lookup yourself, you can make it work. I tested this by creating 2 tables. tbl1 and tbl2. and a form (aform)

    tbl1 has 5 fields one,two,three,four & Five. Text 30
    Primary key one
    one = tablerelation tbl2


    tbl2 has 5 fields aaa,bbb,ccc,ddd,eee Text 30.
    Primary key aaa,bbb,ccc

    in the onlookup trigger of field one

    theform = GLOBAL of AFORM
    RECORD = GLOBAL of tbl2

    theform.RUNMODAL;
    theform.GETRECORD(record);
    one := record.aaa;
    two := record.bbb;
    three := record.ccc;

    Hope this helps

    regards

    Craig Needham
  • DennisDennis Member Posts: 25
    Instead of a simple theForm.RUNMODAL, you might want to use

    IF record.GET(aaa,bbb,ccc)THEN; // This will select the latest selected record
    theForm.SETRECORD(record) // This will set the view to that record
    IF theFORM.RUNMODAL = ACTION::LookupOK THEN BEGIN
    theFORM.GETRECORD(record)
    one := record.aaa;
    two := record.bbb;
    three := record.ccc;
    END;

    // the 'IF theFORM.RUNMODAL = ACTION::LookUpOK THEN BEGIN' makes sure that when a user hits escape or presses the cancel button, no update will happen.

    Dennis

    [This message has been edited by Dennis (edited 01-02-2000).]
    Dennis van Es
    Qwinsoft BV
    The Netherlands
  • jpjp Member Posts: 47
    Mitch:

    The code you are looking for is similar to the Sales Line table, Appl.-to Item Entry field, OnLookup trigger. It calls a function that lets the user select an Item Ledger Entry, and fills the Location Code, Lot No., Serial No., etc. from the chosen record.



    -jp
    -jp
  • Steve_PostSteve_Post Member Posts: 3
    First take a look at the salesline table 37 function BlanketOrderLookup
    1. set a local variable in the function (local seems cleaner than a global but global will work.
    2. clear your variable
    3. set the appropriate key if needed
    4. set ranges and filters if needed to narrow the choices that will appear in the lookup form
    5. use the if statement to see if the form.runmodal Action returns a lookupOK (i.e. true)
    6. Salesline2 is now the specific record you picked in the lookup form
    7. You can now assign as many fields as you like from the returned record.
    8. Some rules If a lookup is written in a form's control's lookup trigger that overrides the table lookup(code or property). If a lookup is written in a table's field's trigger that overrides the table property lookup.
    9. one gotcha --- If there is code in the table's field's trigger Even if it is remmed out or only a comment your property lookup will not work. This one took a long time in a bug hunt.

    Code from BlanketOrderLookup
    2. SalesLine2.RESET;
    3. SalesLine2.SETCURRENTKEY("Document Type",Type,"No.");
    4. SalesLine2.SETRANGE("Document Type","Document Type"::"Blanket Order");
    4. SalesLine2.SETRANGE(Type,Type);
    4. SalesLine2.SETRANGE("No.","No.");
    4. SalesLine2.SETRANGE("Bill-to Customer No.","Bill-to Customer No.");
    4. SalesLine2.SETRANGE("Sell-to Customer No.","Sell-to Customer No.");
    5. IF FORM.RUNMODAL(FORM::"Sales Lines",SalesLine2) = ACTION::LookupOK THEN BEGIN
    6,7. SalesLine2.TESTFIELD("Document Type","Document Type"::"Blanket Order");
    7. "Blanket Order No." := SalesLine2."Document No.";
    7. VALIDATE("Blanket Order Line No.",SalesLine2."Line No.");
    END;

    sorry i was long winded but I wanted to be clear as possible.

    Steve Post
    Steve Post
    Aston IT Indiana
    Indianapolis IN USA
Sign In or Register to comment.