button to make an record in the table
There's a quick entry page.
It has a dynamic selection field Project3
It has a dynamic selection field expenses
a number field amount
a text field comment
a image field Image
I need a formula for digging to select the desired project in the table project1 which contains a subtable expenses and makes a record there in the fields with the same names.
Reference field project2
let thisRec := this;
let projRec := first(select Project1 where Project = thisRec.Project3);
if projRec != null then
(create 'Expanses name').(
Project2 := projRec;
Expenses := thisRec.Expenses;
Amount := thisRec.Amount;
Comment := thisRec.Comment;
Image := thisRec.Image
);
alert("Expense record created.")
else
alert("Project not found.")
end
alert "Expense record created."
thanks
4 replies
-
You will need two create() commands. Something like:
let thisRec := this; let projRec := record(Project1,number(Project3)); if projRec != null then let newProj := (create Project1); (create 'Expanses name').( Project2 := newProj; Expenses := thisRec.Expenses; Amount := thisRec.Amount; Comment := thisRec.Comment; Image := thisRec.Image ); alert("Expense record created.") else alert("Project not found.") end -
oops, sorry for mis-reading the issue. Try:
let thisRec := this; let projRec := record(Project1,number(Project3)); if projRec != null then var share := shareFile(thisRec.Image); var fileName := extractx(text(thisRec.Image), "\/(.*)", "$1"); let newExpense := (create 'Expanses name'); newExpense.( Project2 := projRec; Expenses := thisRec.Expenses; Amount := thisRec.Amount; Comment := thisRec.Comment; Image := importFile(newExpense, share, fileName); unshareFile(Image) ); alert("Expense record created.") else alert("Project not found.") endLines 4,5,12,& 13 are new because to copy an image file between records goes through a different method. Also it only works in the Cloud version as it uses the shareFile() command.
If you are using dynamic fields then you should get comfortable using the record() command as it is a faster way of getting the selected record.
Content aside
- Status Answered
- 2 days agoLast active
- 4Replies
- 29Views
-
2
Following
