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
-
This is possible but I need more information of how your table and relations look like, and which fields must be updated.
Steven
-
Table : ITEMS
Fields:
ITEM_CODE: Text
HEADING: Text
S_CODES: linked to Table S_CODESUsing fields
Source_Code: Text
S_DESCR: TextTable : S_CODES
Fields:
Source_Code: TextS_DESCR: Text
When editing records to ITEMS, I would like a quick way (ie. BUTTON) to set the value of
Source_Code to « 002 »
andS_CODES.S_DESCR to « Old Town Enterprise »
Alternatively, if I could set the default value of
Source_Code to « 002 »
andS_CODES.S_DESCR to « Old Town Enterprise »
Thank you
-
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_DESCRIt'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.
-
EDIT: first line of the code
let me := this;
is unnecessary...
-
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.SDESCRand 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?
-
Most of the code can be found here:
https://ninox.com/en/manual/calculations/reference-of-functions-and-language
-
Thanks so much - I will check it out
-
May I ask you:
S_CODES: linked to Table S_CODES
Is it 1:N or N:1?
-
In the fiels list for Items S_CODES is listed as -> S_CODES
I hope this answers the questionThank you
-
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?
-
Yes, I think that is a help. Thank you very much
-
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
- 4 yrs agoLast active
- 12Replies
- 1674Views