0

Can I create a button that will fill a linked field with a set value?

Since I have many records with a recurring text value , I am looking for a quick way to update this field without opening the ralated table each time. I do need to allow for those times when it might be differrent. I seems that it is not possible to set a default value for a linked field, unless, of course, I am just missing something. Thank you

12 replies

null
    • Ninox partner
    • RoSoft_Steven.1
    • 3 yrs ago
    • Reported - view

    This is possible but I need more information of how your table and relations look like, and which fields must be updated.

    Steven

    • don
    • 3 yrs ago
    • Reported - view

    Table : ITEMS

    Fields:
    ITEM_CODE: Text
    HEADING: Text
    S_CODES: linked to Table S_CODES

    Using fields
    Source_Code: Text
    S_DESCR: Text

     

    Table : S_CODES
    Fields:
    Source_Code: Text

    S_DESCR: Text

     

    When editing records to ITEMS, I would like a quick way (ie. BUTTON) to set the value of

    Source_Code to « 002 »
    and

    S_CODES.S_DESCR  to « Old Town Enterprise »

     

    Alternatively, if I could set the default value of

    Source_Code to « 002 »
    and

    S_CODES.S_DESCR  to « Old Town Enterprise »

     

    Thank you

    • Ninox partner
    • RoSoft_Steven.1
    • 3 yrs ago
    • Reported - view

    Here you go:

    let me := this;
    let i := first(select S_CODES where Source_Code = "002");
    S_CODES := i;
    Source_Code := i.Source_Code;
    S_DESCR := i.S_DESCR

    It's possible you have to put the fieldnames with a underscore between single quotes e.g. : 'S_DESCR' := i.'S_DESCR' (not sure bout that)

    Steven.

    • Ninox partner
    • RoSoft_Steven.1
    • 3 yrs ago
    • Reported - view

    EDIT: first line of the code

    let me := this;

    is unnecessary...

    • don
    • 3 yrs ago
    • Reported - view

    Hi, I got an error message indicationd "Field not found" so I tried changing the field names to remove the underscore:

    let i := first(select S_CODES where SourceCode = "002");
    S_CODES := i;
    SourceCode := i.SourceCode;
    SDESCR := i.SDESCR

    and I am still getting field not found:SourceCode at line 4 column 13

    Thanks again, sorry to bug you, is there a manua for writing code?

    • Ninox partner
    • RoSoft_Steven.1
    • 3 yrs ago
    • Reported - view
    • don
    • 3 yrs ago
    • Reported - view

    Thanks so much - I will check it out

    • Alain_Fontaine
    • 3 yrs ago
    • Reported - view

    May I ask you:

    S_CODES: linked to Table S_CODES

    Is it 1:N or N:1?

    • don
    • 3 yrs ago
    • Reported - view

    In the fiels list for Items S_CODES is listed as -> S_CODES
    I hope this answers the question

    Thank you

    • Alain_Fontaine
    • 3 yrs ago
    • Reported - view

    With a left to right arrow, if you click on that line in the list it will open a detailed view titled "Reference from ITEMS to S_CODES (N : 1)".

    If, in the definitions of the "Source_Code" and "S_DESCR" fields of the "S_CODES" table, you put the desired values in the (well-named) "Default value" box, those fields get that desired value each time a new record is created. Is it what you need?

    • don
    • 3 yrs ago
    • Reported - view

    Yes, I think that is a help. Thank you very much

    • don
    • 3 yrs ago
    • Reported - view

    Hello again,
    I found it worked coded this way:

    let me := this;
    let i := first(select S_CODES where Source_CODE = "002");
    S_CODES := i;
    S_CODES.(Source_CODE := i.Source_CODE);
    S_CODES.(S_DESCR := i.S_DESCR)

    Thanks again for your help

Content aside

  • 3 yrs agoLast active
  • 12Replies
  • 1670Views