Client script is not working on my Instance.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā04-22-2024 11:21 PM - edited ā04-22-2024 11:26 PM
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā04-23-2024 02:04 AM
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā04-23-2024 02:30 AM
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā04-23-2024 02:52 AM
As in my script I haven't give field value programmatically but still it doesn't work for existing record.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā04-23-2024 02:59 AM
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā04-23-2024 03:38 AM
I simply tried this onLoad script, even this is not working on existing record.