Search code examples
lotus-noteslotus

Update fields on form from fields on another (Lotus Notes)


I have a list of printers stored in a printer keyword section that have fields like the serial of the ink they use for each of their colours and such. I want to make it so when I create a new user form and say that they have "X" Printer, it will grab that keyword form and pull all the ink types that it uses and save itself on the user form.

@GetDocField is the method I know I have to use but I do not know how to acquire the correct form saved from a list of forms based on a selection I make on which printer the user has.


Solution

  • Use @DbLookup to get the data from printer documents.

    FIELD ink1 := @DbLookup(""; ""; "viewPrinters"; "XPrinter"; "ink1"; [FAILSILENT]);
    

    The line above reads item "ink1" in printer's "XPrinter" document in view "viewPrinters" in current database and writes it to item "ink1" in current document. You would copy every field this way. The view "viewPrinters" has to to have a first sorted column with the printer names.

    It might be more efficient to define all fields you want to grab in a column separated by a special character and get them all at once with

    FIELD allFields:= @DbLookup(""; ""; "viewPrinters"; "XPrinter"; 2; [FAILSILENT]);
    

    You can stay with @GetDocField too if you read the document ID of your printer document:

    _docId := @Text(@DbLookup(""; ""; "viewPrinters"; "XPrinter"; "";
                                                  [RETURNDOCUMENTUNIQUEID]));
    @If(@IsError(_docId); @Return(""); "");
    FIELD ink1 := @GetDocField(_docId: "ink1");
    

    It might be even more efficient to use LotusScript instead. But i assumed from your question you prefer a formula solution.