138
Views
3
Comments
Javascript set up
Question

Hi, I have some script that looks like this. I've created a screen action, set the destination of each input to this screen action. and within the action used an assign to turn a local variable (showAlert) to true. followed by a RunJavaScriptAction with the input set to the variable. When running the application though it says true is undefined. I'm guessing I have it set up incorrectly. What's the problem?

2019-11-11 17-10-24
Manish Jawla
 
MVP

Hi Jaret,

Please check the below link, hope this helps

https://ujap.de/index.php/view/JavascriptCloseHook

Regards,

Manish Jawl;a

2025-08-22 10-19-44
Pramod Jain
 
MVP

Hi Jaret,

Is it possible for you to share the sample oml so that i can try it in my environment.


Regards,

-PJ-



2021-03-18 21-03-15
Benjith Sam
 
MVP

Hi Jaret,

I just tried to implement the same scenario in a sample application and in my observation it's working as expected.

Referring to the shared screen shot, I assume that you are considering the mentioned case for an OS 11 traditional web application. 


1) Defined the Screen level JS Script as mentioned below:


2) Mapped a screen action called OnChange to the Input Control:

3) OnChange Screen Action flow:

Introduced a RunJavaScript node within the action flow (referenced from HttpRequestHandler Module)



Used JS Code Snippet

"
console.log(showAlert); // to check the previous value

showAlert = true; // updating the showAlert global value
"


Note: Console.log() statement are used to check the declared global variable existence and its latest value.


IMP Note: I observed that you mentioned a return statement (of string type value) at the end of the function definition. The string provided by the function will no longer be shown in the dialog because of some security concerns.

Refer this link: https://stackoverflow.com/questions/40570164/how-to-customize-the-message-changes-you-made-may-not-be-saved-for-window-onb


Hope this helps you!


Regards,

Benjith Sam


Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.