Page 1 of 1

Splash Screen using setTimeout

Posted: Thu Oct 07, 2021 8:44 pm
by RichDotsonMTD
I created a record format in my UI to display a splash screen prior to running a long process that pulls data from our Salesforce org. I use the javascript example that is on the ProfoundUI doc website and other forum posts to set a timer in the onLoad event and clear it in the onSubmit event. The auto-submit process does not work the first time I click on the button that initiates the data pull but it does auto-submit every time after that first time.

I've included screen captures and the UI JSON as an attachment.

How can I get it to work the first time the process is initiated?

onLoad Event Javascript

Code: Select all

window.savedTimer = setTimeout(function() {
  setTimeout( function() { pressKey("ENTER"); }, 500);
}); 
onSubmit Event Javascript

Code: Select all

window.savedTimer = null;
if (window.savedTimer) {
  window.cancelTimeout(savedTimer);
  window.savedTimer = null;
}
splash.PNG
splash.PNG (248.32 KiB) Viewed 5232 times

Re: Splash Screen using setTimeout

Posted: Thu Oct 07, 2021 9:55 pm
by Scott Klement
Is it possible that part of the Profound UI application is still communicating with the server in the background?

If you try to submit the screen when it hasn't finished loading, or is still finishing up its communication with the IBM i to draw the screen, then it will ignore the screen submission... expecting that you'll try again later. That's what comes to mind when reading about your dilemna.

Have you tried increasing the time on the timeout? Or, making a simpler screen?

Re: Splash Screen using setTimeout

Posted: Fri Oct 08, 2021 7:20 am
by RichDotsonMTD
I removed the image and increased the time on the timeout to 10000 but that did not change anything.

Code: Select all

window.savedTimer = setTimeout(function() {
  setTimeout( function() { pressKey("ENTER"); }, 10000);
});

Re: Splash Screen using setTimeout

Posted: Fri Oct 08, 2021 12:15 pm
by lyarbrough
Hi Rich,

It looks like there are some mistakes in your JavaScript code that could be causing the problem you're experiencing. Please edit your onload event to use the following:

Code: Select all

window.savedTimer = setTimeout(function() {
	window.savedTimer = null;
	pressKey("ENTER");
}, 500);
and your onsubmit event to use this:

Code: Select all

if (window.savedTimer) {
	clearTimeout(window.savedTimer);
	window.savedTimer = null;
}
There's more information about this here: https://docs.profoundlogic.com/x/qgCzAQ.

Could you give this a try?

Re: Splash Screen using setTimeout

Posted: Fri Oct 08, 2021 12:59 pm
by RichDotsonMTD
Hi Lillie,

I Copied/Pasted the Javascript from your post and placed it in my UI but that didn't fix it.

Re: Splash Screen using setTimeout

Posted: Sat Oct 09, 2021 12:11 am
by jaliling
Hi, I have checked your display file and it looks like you have set the "external javascript" property of your Splash screen to a CSS URL which supposedly should be a Javascript file.
splash.PNG
splash.PNG (11.34 KiB) Viewed 5163 times
Could you remove that and try running the program again? I was able to make it work in my test environment with your Splash screen by simply removing that.

If you need to add more than one external CSS files, you could do a right-click on the "external css" property and the "Add Another External CSS" option will allow you to include additional external CSS files.
add external css.PNG
add external css.PNG (14.65 KiB) Viewed 5163 times

Best regards,
Joe

Re: Splash Screen using setTimeout

Posted: Sat Oct 09, 2021 8:33 am
by RichDotsonMTD
Joe,

That sort of fixed it. It works great if I display the splash screen from the "main" page and return to the main page.

It does not work correctly when:

1. I display the splash screen and then display a secondary popup window. It doesn't seem to be turning the timer off because the second popup window is repeatedly submitted back to the server.

2. The splash screen does not appear at all if I try to display the if from a secondary popup window.

Thanks for all the help.

-Rich

Re: Splash Screen using setTimeout

Posted: Sat Oct 09, 2021 11:26 am
by RichDotsonMTD
Joe,

I played around with some of the property values on all my record formats and I was able to get this to work on all screens.

Thanks for your help on this. The ProfoundUI support was superb as always.

-Rich

Re: Splash Screen using setTimeout

Posted: Sat Oct 09, 2021 2:06 pm
by jaliling
Hi Rich,

We're so happy to hear that you got it sorted it out!

Best regards,
Joe