How to add buttons that create new records or search records in a table
The little + and magnifier icons on subtables are quite small, and I have team members who need big coloured buttons with writing on so they know how to search or create records! What formula should I put on the buttons to achieve this? Can't figure this out from the manuel, sorry!
28 replies
-
I have a table named Plants, and it has a subtable name PlantLog.
This is the script I use on a button on the Plant form to create a new record in PlantLog. It also causes the new PlantLog record to open.
let myID := Id;
let NN := (create PlantLog);
NN.(Plants := myID);
popupRecord(record(PlantLog,number(NN.Id))) -
Ah, that's useful. Thanks. Sorry for the dumb question, but are Id, NN and NN.Id fixed code terms or do I need to replace them with specific terms from my table?
-
Id is fixed for every record.
NN can be whatever you want. In my case it stands for new note. It is a variable that is only used in the button script.
-
My version of your script is:
let myID := Id;
let NN := (create IMAGES);
NN.(LEADER := myID);
popupRecord(record(IMAGES,number(NN.Id)))It's throwing up the error message: Expression must return a number or record id: myID at line 3 column 19.
I'm in LEADER, trying to create a new record in IMAGES. What's going wrong?
-
Hmm...
in the line
NN.(LEADER := myID);
LEADER is the name the reference back to the LEADER table. I think be default the link back is named the same as the table, but the link can be renamed to something else. If you renamed the reference in IMAGES back to LEADER, you will need to make sure the third line used the reference name, not the LEADER table name.
that may not be the issue, but that is my first thought
-
Maybe also change the first line to
let myID := number(Id);
But I don't have to do that.
-
Maybe also change the first line to
let myID := number(Id);
But I don't have to do that.
-
Thanks - I'll try fiddling around with that!
-
let myID := Id;
let NN := (create IMAGES);
NN.(LEADER := myID);
popupRecord(record(IMAGES,number(NN,Id)))(NN,Id))) and not (NN.Id)))
Nick
-
Brilliant - adding let myID := number(Id); fixed it. If I stare at it long enough maybe I'll figure out why!
-
David.. it is a "feature".. the Id field is stored internally as a number field.. but when you simply compare them.. it is a text field.. I was snagged by this "got-cha" when writting an application to manage our Statement Of Works (SOW)/Contracts.. and struggled for a while.. until Support clued me in.. :)
-
how can do that? popupRecord(record(IMAGES,number(NN,Id)))
because for me i have a error : function not defined number(nid,nid)
I dont find in documentation. it's possible?
-
it is
number(NN.Id)
It is getting the record ID of the newly created record as a number.
-
it is
number(NN.Id)
It is getting the record ID of the newly created record as a number.
-
it's ok, because rtim say (NN,id) and the just way is (NN.id)
-
Wait a minute, this didn't work quite as well as I thought. The script is:
let myID := number(ID);
let NN := (create IMAGES);
NN.(LEADER := myID);
popupRecord(record(IMAGES,number(NN.Id)))It calls up the IMAGE popup, lets you insert pictures, but it doesn't assign the new IMAGE record to the LEADER record where the script is. Is something missing?
-
That should be what the third line does.
NN.(LEADER := myID);
It sets the reference NN.LEADER in the new IMAGES record to point to the record ID of the LEADER record where the the script is run.
Is the reference in IMAGES record back to the LEADER table named "LEADER"?
-
Maybe the third line needs to be
NN.(LEADER := number(myID));
-
Seems like you need to explicilty make sure a record Id is a number.
It's weird, because the script works for me without using number() on lines 1 and 3.
It also works for me when I use number(), so I guess I need to start always using number() in these types of cases.
-
I wonder if changing the first line to
let myID := this;
would avoid all the hassle of having to use number().
-
blackie, that last suggestion fixes it. Many thanks. So simple!
-
If this script creates a new record in IMAGES:
let myID := this;
let NN := (create IMAGES);
NN.(LEADER := myID);
popupRecord(record(IMAGES,number(NN.Id)))... how do I need to adjust it to open an existing record in IMAGES? I'm placing several images on one record rather than having a different record for each image).
-
If IMAGES already exists and is linked, you only need something like
popupRecord(record(IMAGES,number(this.IMAGES)))
-
Ah, brilliant. Thanks!
-
You could include an if statement that checks the IMAGES link. If it is null, it can create IMAGES and link to it.
let myID := this;
if myID.IMAGES = null then
let NN := (create IMAGES);
NN.(LEADER := myID);
end;
popupRecord(record(IMAGES,number(myID.IMAGES)));
Content aside
- 4 yrs agoLast active
- 28Replies
- 12494Views