- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-09-2022 07:29 PM
Hello,
I would like to know if there is any way where we can check a field in a form before it is updated for any vertical tab using a before business rule.
in my client script
//var recommendation = g_form.getValue('u_recommendation');
//g_form.setValue('u_recommendation', u_recommendation.replace(/\v/g, ''));
I would like to create a server version of it using before business rule. Is it possible?
Regards,
Rain
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-09-2022 08:58 PM
Hi @Rain Vaine ,
Yes, using before BR you can do this. There are two objects available there current and previous . Using previous you can access the value of the field that was stored in the field when form was loaded and using current you can get the value of the field that is available whe it's going to the database.
previous.getValue("state") ; // Refers to the state value when form was loaded
current.getValue("state"); //Refres to the state value when form was submitted/saved
I hope this helps.
Regards,
Kamlesh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-09-2022 07:42 PM
Hi, to utilize server-side scripting\functionality from client side you would normally use GlideAjax to call a client callable script-include.
GlideAjax | ServiceNow Developers
A before business rule would only be triggered when the record was being inserted\updated, it would not be called from the UI.
If you intention is to check\update the record as it is being submitted to the database? then a before BR is the correct way to do this.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-09-2022 08:58 PM
Hi @Rain Vaine ,
Yes, using before BR you can do this. There are two objects available there current and previous . Using previous you can access the value of the field that was stored in the field when form was loaded and using current you can get the value of the field that is available whe it's going to the database.
previous.getValue("state") ; // Refers to the state value when form was loaded
current.getValue("state"); //Refres to the state value when form was submitted/saved
I hope this helps.
Regards,
Kamlesh