-
I hope Emanuel doesn't mind me jumping in... I haven't seen this before so I wanted to try it. My solution is a little different, but with code there is always more than one way to arrive at a similar result. You would enter this in "Trigger on create" in the edit fields screen.
let prvId := number(last(select Table1).Id) - 1;
let newRec := this;
newRec.(City := text((select Table1)[Id = prvId].City));
newRec.(State := text((select Table1)[Id = prvId].State))
This copies the values from the City and State fields of the previous record to the new record.
-
Sean, Re: your script to enter a City and State in a new record.
let prvId := number(last(select Table1).Id) - 1;
let newRec := this;
newRec.(City := text((select Table1)[Id = prvId].City));
newRec.(State := text((select Table1)[Id = prvId].State))
This copies the values from the City and State fields of the previous record to the new record.I tried your script to populate a field "Start Miles" with the number displayed in the previous record field "Stop Miles" in order to eliminate constantly typing in numbers. This is the script I attempted, but I continuously get an ERR("Symbol expected: )"); Miles
?!?
It's obvious that I'm not a database coder, but would appreciate any help you could provide. I'm using an iPhone 7.
-
aztory, I finally got this to work...
let prvId := number(last(select YourTableName).Id) - 1;
let newRec := this;
newRec.('Start Miles' := number((select YourTableName where Id = prvId).'Stop Miles'))
I tried to do it on my iPhone 8 first and got most of the way there, but I had to switch to my Mac to finish it. You get some error feedback on the Mac app that you don't get on the iPhone app. The code above works on both my Mac and iPhone.
-
Sorry
I have a question, if the value are fron another tables?
let prvId := number(last(select Jornales).Id) - 1;
let newRec := this;
newRec.(Fecha := text((select Jornales)[Id = prvId].Fecha));
newRec.(turno := text((select turno)[Id = prvId].turno));
newRec.(labor := text((select labores)[Id = prvId].labor))Thanks