Client script is not working on my Instance.

aakankshapl
Tera Expert

Hello
On my instance any type of client script is not working. My story is stuck from two days because of this issue.
What could be reason and solution for this to resolved.
Your help will be alot for me 

Thanks & Regards,
Aakanksha Lavande

21 REPLIES 21

actually my script is working on PDI, but on customer instance it only working when the change happen on new record, it doesn't working on existing record.

@aakankshapl 

The issue you're encountering where the script only works when the change happens on a new record but not on an existing record might be due to the form context in which the onChange client script is triggered.

In ServiceNow, onChange client scripts are typically triggered when a field value changes on a form. However, there are differences in behavior between new records and existing records.

For existing records, the onChange client script may not be triggered if the field value is changed programmatically (e.g., via a script) rather than by user interaction. This could explain why the script works for new records (where the user is directly interacting with the form) but not for existing records (where the field value might be changed via script or some other means).

 

To address this issue, you might consider using a different client script event or a combination of client script to ensure that the validation logic is applied consistently for both new and existing

records.

 

Please Mark āœ…Correct if this solves your query and also mark šŸ‘Helpful if you find my response worthy based on the impact.

 

Thanks

As in my script I haven't give field value programmatically but still it doesn't work for existing record.

@aakankshapl 

You need to write your logic in on load client script as well or in your onchange client script instead of return on isLoading, write your script to run on load as well.

 

Please Mark āœ…Correct if this solves your query and also mark šŸ‘Helpful if you find my response worthy based on the impact.

 

Thanks

aakankshapl_0-1713868649013.png

I simply tried this onLoad script, even this is not working on existing record.