When saving this BO Rule that contains this:
But it doesn't in my case.
Its just a Notification that displays at the top of the screen and then goes away after a time.
I've used this before in Processes, either started from a Menu or a Button on a Form.
But this is from a Rule in the BO when the BO is getting saved.
Under a specified condition, I want the JS to run to display a msg.
Don't know why I'm having a brain fart on how to get this accomplished.
PS _ Same result for DISPLAY MESSAGE ASYNCH
I get this warning:
At runtime this is shown:
I know why all this is happening, because the JS being called may have an Alert/UI instruction that requires user input.EXEC_SCRIPT from a Rule will not run.
EXEC_SCRIPT from a Rule will not run.
Click Here to see a collection of my tips & hacks on this forum. Or search for "JaymerTip" in the search bar at the top.
Jaymer
Aware Programming & Consulting - Tampa FL
Jaymer
Aware Programming & Consulting - Tampa FL
Re: EXEC_SCRIPT from a Rule will not run.
I could be wrong (usually am) but I thought the ONLY user interaction a rule can have is a REPORT ERROR. Anything else has to be in a process.
So, why not have this line of code call a process to run the EXEC_SCRIPT? Yea, I know thats 1 extra line of code and an additional process....
Bruce
So, why not have this line of code call a process to run the EXEC_SCRIPT? Yea, I know thats 1 extra line of code and an additional process....
Bruce
Re: EXEC_SCRIPT from a Rule will not run.
Ya
Did that
Got the exact same msg at runtime
Did that
Got the exact same msg at runtime
Click Here to see a collection of my tips & hacks on this forum. Or search for "JaymerTip" in the search bar at the top.
Jaymer
Aware Programming & Consulting - Tampa FL
Jaymer
Aware Programming & Consulting - Tampa FL
Re: EXEC_SCRIPT from a Rule will not run.
I have worked around this before but can't remember how. Have you tried having the JS in a JS file and then calling that file instead of calling the JS function directly? (or is that what you are doing).
Another thing you could try is run some JS from the EXEC_SCRIPT that only set a SessionStorage flag e.g Notify=1 and then have another JS script running with setInterval checking every second or so for that flag and executes some JS if its 1 and then reset it back to 0. I can't remember if ALL JS is "blocked" when running EXEC_SCRIPT but if it isn't, this should work even though its a clunky workaround.
A third thing is of course changing the design of the user interaction i.e where it started from etc. etc. and make sure that is a process i.e don't run it at all via rules.
A smarter and better way probably exists, these were just random things coming to my mind when sitting and having lunch and being a bit bored .
Another thing you could try is run some JS from the EXEC_SCRIPT that only set a SessionStorage flag e.g Notify=1 and then have another JS script running with setInterval checking every second or so for that flag and executes some JS if its 1 and then reset it back to 0. I can't remember if ALL JS is "blocked" when running EXEC_SCRIPT but if it isn't, this should work even though its a clunky workaround.
A third thing is of course changing the design of the user interaction i.e where it started from etc. etc. and make sure that is a process i.e don't run it at all via rules.
A smarter and better way probably exists, these were just random things coming to my mind when sitting and having lunch and being a bit bored .
Henrik (V8 Developer Ed. - Windows)
Re: EXEC_SCRIPT from a Rule will not run.
yes, i load JS from /Custom/JS
How would Aware know to allow some JS and not others? It has no idea what the JS is doing.hpl123 wrote: ↑Sat Feb 11, 2023 8:18 am Another thing you could try is run some JS from the EXEC_SCRIPT that only set a SessionStorage flag e.g Notify=1 and then have another JS script running with setInterval checking every second or so for that flag and executes some JS if its 1 and then reset it back to 0. I can't remember if ALL JS is "blocked" when running EXEC_SCRIPT but if it isn't, this should work even though its a clunky workaround.
Can't really do this. The rule is in place. Only other option is to add a process "On Save", and then scatter that extra crud all over an app.
There are several places I want to give this simple notification in the app.
Exactly what I'm doing is this:
On a form a user enters any type of field.
On Save of a form a rule checks for a condition and does something (send email, logs something, whatever).
Instead of a Dialog box which slows the user down and requires a click to close, I just use this code:
Code: Select all
function notifyBar(theMsg) {
if(! $('.alert-box').length) {
$('<div class="alert-box alert-box-wide alert-box-left success" >' + theMsg + '</div>').prependTo('body').delay(750).fadeOut(300, function() { $('.alert-box').remove(); });
};
Click Here to see a collection of my tips & hacks on this forum. Or search for "JaymerTip" in the search bar at the top.
Jaymer
Aware Programming & Consulting - Tampa FL
Jaymer
Aware Programming & Consulting - Tampa FL
Re: EXEC_SCRIPT from a Rule will not run.
There was a discussion that covered most of these points/issues 3 years ago:
https://www.awareim.com/forum/viewtopic ... 953#p52953
v8.5 introduced a way for DISPLAY MESSAGE ASYNCH to work IF
you enabled Dynamic and DO NOT Run on Server.
Thats fine, but not for what I'm doing. In my case, that would display the msg ("Email has been sent", for example) before the record was saved. And it might not actually get saved.
So that was a nice improvement, just doesn't apply to me here.
https://www.awareim.com/forum/viewtopic ... 953#p52953
v8.5 introduced a way for DISPLAY MESSAGE ASYNCH to work IF
you enabled Dynamic and DO NOT Run on Server.
Thats fine, but not for what I'm doing. In my case, that would display the msg ("Email has been sent", for example) before the record was saved. And it might not actually get saved.
So that was a nice improvement, just doesn't apply to me here.
Click Here to see a collection of my tips & hacks on this forum. Or search for "JaymerTip" in the search bar at the top.
Jaymer
Aware Programming & Consulting - Tampa FL
Jaymer
Aware Programming & Consulting - Tampa FL
Re: EXEC_SCRIPT from a Rule will not run.
Another thing you possibly could do is run some JS when the form is opened up that adds an event listener tied to your save button which then executes when the save button is clicked. For this to work the condition you mention (and all other needed parts) should of course be available to the JS.
This shouldn't be some cumbersome. A better solution for this would be nice i.e Aware removing all of these restrictions on EXEC_SCRIPT when run from a rule.
This shouldn't be some cumbersome. A better solution for this would be nice i.e Aware removing all of these restrictions on EXEC_SCRIPT when run from a rule.
Henrik (V8 Developer Ed. - Windows)
Re: EXEC_SCRIPT from a Rule will not run.
I feel that EXEC_SCRIPT is not your average-user's function.
So if you're gonna use it, its OK to get the warning during development, but its kinda "Use at your own risk" if you go past that.
In my case, I definitely don't want to "Run on Server",
but I can't turn that off unless its Dynamic, which it can't be.
Not sure what would be an easy fix for Vlad.
Click Here to see a collection of my tips & hacks on this forum. Or search for "JaymerTip" in the search bar at the top.
Jaymer
Aware Programming & Consulting - Tampa FL
Jaymer
Aware Programming & Consulting - Tampa FL