Best approach to check if field is empty while moving to next state.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-25-2023 05:23 AM
Hello
For problem management - when user opens a form, field "group_by" is filled from "client script" which is working "onLoad"
Because of some issues in the past, this field sometimes was empty.
I want to make some "security" that when I press ASSESS button in problem record, system check if "group_by" is empty - if empty fill it by the same "client script" or other one.
What is the best approach to finalize this requirement. Which elements I could use to make it fast and efficient ?
Thx for advise.
BR
Dom
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-25-2023 05:36 AM
Hi Dom,
In UI action Assess check if group by field is empty then don't update the state.
Regards,
Dhanashree
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-25-2023 05:41 AM
Hello @Don Dom
1) You mentioned that you already have a Client Script that fills the "group_by" field when the form is loaded. Ensure this Client Script is working correctly and is attached to the Problem form's "OnLoad" event.
2) Create a Business Rule to run when the "ASSESS" button is clicked. Follow these steps:
- Set the "When to run" field to "Before" and choose the table "Problem [problem]"
- In the "Advanced" tab, specify a condition to check if the "group_by" field is empty
- In the "Scripts" section, add a script to call the same Client Script that fills the "group_by" field when the form is loaded. You can use the g_scratchpad object to execute the script from the Client Script. For example:
var gr = new GlideRecord('problem');
gr.get(current.sys_id);
var script = 'your_client_script_name_here';
gs.include(script, gr);
3) You can also use a UI Policy to make the "group_by" field read-only or hidden when the form loads, to prevent users from manually modifying
Please mark Helpful
Regards
Prashant ahire