Reset value in a OnChange Client Script

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-21-2023 10:06 AM - edited 06-21-2023 10:39 AM
Hi,
I've created an onChange client script on field 'approval' in a table. Approval field by default is 'Pending'. If the state in the same table is not 'in Progress' and when the approval field is moved to 'Requested' it triggers for approval. I've written script to throw an error when state is not 'In Progress' and approval is moved to 'Requested' from 'Pending'. Till here it is working fine, but if I want to reset the value of approval back to 'Pending'. I tried g_form.setValue, but it is going in a loop i.e. same client script is running again.
The same client script has a GlideAjax call and in the script include I am having gs.info defined. So when this client script runs the logs keeps on adding which means that the client script is going in a loop because trigger condition field and resetting field are both same.
Is there a solution to reset the approval back to previous value in same client script?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-21-2023 10:15 AM
Did you try using oldValue property available in Client script?
Please mark my response as correct and helpful if it helped solved your question.
-Thanks

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-21-2023 10:39 AM
Yes, I tried. It's resetting the value to old value. The same client script has a GlideAjax call and in the script include I am having gs.info defined. So when this client script runs the logs keeps on adding which means that the client script is going in a loop because trigger condition field and resetting field are both same.