Hello,
Is it possible in Rollbase to insert Javascript functions in Triggers ?
I would try it, but not functional.
When I put key-word "function" an error was report.
Thanks,
The basic difference between a field update trigger and an object script trigger would be the former expects a value back. Your code would only seem logical but Rollbase norms require that it be of the following format
var myVar = setMyVar(); function setMyVar() { return "Toto"; } myVar;
Notice no "return". Update field value triggers expect a value back (you don't need return here) while object script triggers just execute code and have a void return.
I hope this answers your question on either of the trigger types.
Regards,
Santosh
Hi,
This should be possible in Triggers.
Could you please share the sample code that you are trying and the details of the trigger?
Regards,
Mani.
You can use JavaScript in many trigger types, including:
- in "Update Field Value" to calculate new field's value
- in "Object Script" to run any script, which usually includes server-side APIs to manipulate data
Hi,
My sample code.
var myVar = setMyVar();
function setMyVar() {
return "Toto";
}
return myVar;
When I add return value, the code is broken.
The basic difference between a field update trigger and an object script trigger would be the former expects a value back. Your code would only seem logical but Rollbase norms require that it be of the following format
var myVar = setMyVar(); function setMyVar() { return "Toto"; } myVar;
Notice no "return". Update field value triggers expect a value back (you don't need return here) while object script triggers just execute code and have a void return.
I hope this answers your question on either of the trigger types.
Regards,
Santosh
I have always used "return" for Update field value triggers. But I would like use functions and an error was reported.
Now, I know, no use return for this case.
Thank you Santosh. It's work !
You can also try
function setMyVar() {
return "Toto";
}
setMyVar();