Trigger on Open....
- Luis
- 2 yrs ago
- 36replies
Is there any way to trigger actions on open a record? (there are on create and on update)
Background: I am implementing a "cancel / undo" option where I want to rollback the values in case of undo/cancel....
I am basically creating a duplicate record with a "backup" but I was looking forward to having a more elegant option....
thoughts?
cheers
Luis
36 replies
-
- Fred
- 2 yrs ago
- Reported - view
There is not a trigger on Open at the table level. There is one at the DB level.
-
- Leo_Woer
- 2 mths ago
- Reported - view
Hi Fred I am in the position, where I try to delete an image field at opening the record - and that could easily be all the same fields in the table. Any suggestion of how to do this from DB level ?
rgds
Leo
-
- Fred
- 2 mths ago
- Reported - view
Maybe we can look at it from another direction. Question, why do you need this field in this table if you need to delete the contents when you open the record?
What is the field used for? If it is a UI field then maybe consider using a dashboard.
-
- Leo_Woer
- 2 mths ago
- Reported - view
Hi Fred - sorry for late answer, have been away.
It is not a UI field, it is supposed to be hidden, as it only works as a container for the attachment I send in an email. I have tested a lot of things, and it seems to be a combination of a timing problem as the email seems to get send before the the system reacts with the deletion and creation of a new attachment. I can do the delete from a button, however then the automation is in fact non existing. The last thing I tested which seems to work - is doing the deletion and forget the creation, and instead of the creation I update a number field which I call "how many licenses has this person been sent" and then let this field do the creation and sending. Still I have to test a little more, so in the meantime I would appreciate good ideas, I will off course return when I have finished testing of this.
Thank You
Leo
-
- Ninox partner
- RoSoft_Steven.1
- 2 mths ago
- Reported - view
you can insert the function sleep() between your code to have a little time between the deletion/creation and sending the email...
-
- Leo_Woer
- 2 mths ago
- Reported - view
Wouw I didn't know that feature - thanks a lot.
rgds
Leo
-
- Fred
- 2 mths ago
- Reported - view
It cannot find the layout I have in "myFilename"
I am sure that it is because I haven't properly linked the parent and the child correctly and the layout is in the parent table.
If you are running the button from the child and the print layout is in the parent then yes that is the problem.
Generally you want to do things from the parent table if you are trying to create child table records. Well, actually from a dashboard in the end, but that is another discussion. You want to start from the parent table so you can use the [this] function to get the parent record Id then you can link them:
let t := this; let i:= (create childtable); i.( parenttable := t; Licenskort := importFile(this, printAndSaveRecord(this, myFilename), "Licenskort.pdf") )
-
- Leo_Woer
- 2 mths ago
- Reported - view
hi again,
I push the button form the parent, and yes I see that the link creation was missing, however I get the same error - here is the whole script (parent table is "medlemmer":
let myFilename := "";
switch 'Hvilket Licenskort har vedkommende' do
case 1:
(myFilename := "Provisional")
case 2:
(myFilename := "A Licens IPSC")
case 3:
(myFilename := "A+ Licens IPSC")
case 4:
(myFilename := "NROI + RO-steel")
case 5:
(myFilename := "B Licens")
case 6:
(myFilename := "NROI Range Officer")
case 7:
(myFilename := "NROI Range Officer Instructor")
case 9:
(myFilename := "NROI CRO Instructor")
case 10:
(myFilename := "NROI RM Instructor")
case 11:
(myFilename := "NROI Range Officer (Provisional)")
case 12:
(myFilename := "NROI RO-steel")
case 13:
(myFilename := "ActionAir")
default:
" intet valgt"
end;
let t := this;
let xmedlem := Medlemsnr;
let i := (create 'Sendte Licenskort');
i.(medlemmer := t);
i.(Licenskort := importFile(this, printAndSaveRecord(this, myFilename), "Licenskort.pdf"))By the way - I have also tried to use exactly what you wrote : i.(medlemmer := t; Licenskort := importFile(this, printAndSaveRecord(this, myFilename), "Licenskort.pdf"))
rgds
Leo
-
- Fred
- 2 mths ago
- Reported - view
Have you tried hard coding a print layout name to test that it works?
-
- Leo_Woer
- 2 mths ago
- Reported - view
Yes
same result
-
- Fred
- 2 mths ago
- Reported - view
Try changing:
i.(Licenskort := importFile(this, printAndSaveRecord(this, myFilename), "Licenskort.pdf")) to i.(Licenskort := importFile(t, printAndSaveRecord(this, myFilename), "Licenskort.pdf"))
If I'm reading it right, [this] refers to the child table record that was just created (you are in the variable i), so we need to point Ninox back to the parent record.
-
- Leo_Woer
- 2 mths ago
- Reported - view
nope - same result, it can't find the layout
-
- Fred
- 2 mths ago
- Reported - view
Have you tried a print layout name without spaces?
-
- Leo_Woer
- 2 mths ago
- Reported - view
Yes same result - Provisional is without spaces
-
- Leo_Woer
- 2 mths ago
- Reported - view
Fred when creating the child the old fashion way i.e. the plus sign in the child table from the parent view, and then go into the child record I can neither see the layout when going to the print icon - I guess that I have to create alle the 13 layouts also in the child environment - any good idea of how to do it in an easy way ?
rgds
Leo
-
- Fred
- 2 mths ago
- Reported - view
That is one solution, or you can try out solution from this post.
Here is code that works for me:
let t := this; let newChild := (create Table1a); let printVar := printAndSaveRecord(t, "NameSpace"); newChild.( Table1 := t; Image := importFile(newChild, printVar, "bettercode.pdf") )
I learned from the post above that where you put your variables is very important. I originally had the variable printVar outside the newChild and that didn't work. So I put it after newChild and now it works.
I thought that putting printVar before the newChild is the same as putting it after. I didn't realize that putting it after newChild makes it a variable of newChild.
-
- Leo_Woer
- 2 mths ago
- Reported - view
Jacques method works perfectly - thank You for your great help here
rgds
Leo
-
- Fred
- 2 mths ago
- Reported - view
You can also simplify the switch to:
let myFilename := switch 'Hvilket Licenskort har vedkommende' do case 1: "Provisional" case 2: "A Licens IPSC" case 3: "A+ Licens IPSC" case 4: "NROI + RO-steel" case 5: "B Licens" case 6: "NROI Range Officer" case 7: "NROI Range Officer Instructor" case 9: "NROI CRO Instructor" case 10: "NROI RM Instructor" case 11: "NROI Range Officer (Provisional)" case 12: "NROI RO-steel" case 13: "ActionAir" default: " intet valgt" end;
-
- Leo_Woer
- 2 mths ago
- Reported - view
O just remove the line where I force myFilename to Text
-
- Leo_Woer
- 2 mths ago
- Reported - view
No Ninox scripting does not allow it, if I do so Ninox says that the file does not exist
-
- Fred
- 2 mths ago
- Reported - view
If I add a switch to my code from above:
let t := this; let layoutName := switch name do case "bubba": "NameSpace" end; let newChild := (create Table1a); let printVar := printAndSaveRecord(t, layoutName); newChild.( Table1 := t; Image := importFile(newChild, printVar, "bettercode.pdf") )
The code still works fine.
-
- Leo_Woer
- 2 mths ago
- Reported - view
You are right - my mistake - works now. Thanks again for your great contribution
rgds
Leo
-
- Ninox partner
- RoSoft_Steven.1
- 2 yrs ago
- Reported - view
You could use the 'trigger before' view of the TAB element.
-
- Luis
- 2 yrs ago
- Reported - view
RoSoft_Steven
that is an idea yes!
thanks
-
- Leo_Woer
- 2 mths ago
- Reported - view
Thanks Steven. I will try this and return
rgds
Leo
Content aside
- 2 mths agoLast active
- 36Replies
- 504Views
-
5
Following