How to run onload client script conditionally?

Johannes Mweli
Giga Guru

Hi ServiceNow Community Developers,

 

I have an onload client script that runs when the form loads. I would like this script to not run when form loads from a Save action within the current record that I currently have opened on the form. If I come from somewhere else and open the form for instance, I want that onload client script to run. However, if I make some changes on the record while it’s opened and I click Save and the records gets saved and the form reloads I don’t want that script to run at that time because I am already within the record. If I then navigate away from record and then come back and re-open the record then I want it to run. Basically, the script should run only when record opens for the first time coming from somewhere else. Whatever I do on the record and save it the script should not run at that point. It’s a crazy requirement guys but I was wondering if there is a way to do that.

 

Kindly advise please.

 

Thanks,

Johannes

1 ACCEPTED SOLUTION

Community Alums
Not applicable

Hi @Johannes Mweli ,

Unfortunately NO!! you cannot use onLoad Client scripts based on conditions.

That functionality is with Business rules but this runs on the server side not client.

View solution in original post

1 REPLY 1

Community Alums
Not applicable

Hi @Johannes Mweli ,

Unfortunately NO!! you cannot use onLoad Client scripts based on conditions.

That functionality is with Business rules but this runs on the server side not client.