When variable empty in MRVS at Task Level, Abort task submission.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-04-2023 02:44 AM
At task level, how to abort form submission, when a few of the variables are empty in Multi Row variable set?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-04-2023 02:48 AM
you can use before update BR on sc_task and check the MRVS data which is a json string
you need to parse the json and check if your variable is empty or not
what script did you start with?
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-04-2023 03:41 AM
Hi @Ankur Bawiskar
I was doing it through on submit client script as below :
function onSubmit() {
//Type appropriate comment here, and begin script below
var mrvs = JSON.parse(g_form.getValue('short_justification'));
if(mrvs.length == 0){
alert('empty MRVS');
return false;
}}
What code id required in case of BR ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-04-2023 03:44 AM
then you can use onSubmit
In case you wish to use BR then use before update BR with valid conditions
Script
(function executeRule(current, previous /*null when async*/) {
// Add your code here
var parsedData = JSON.parse(current.variables.short_justification);
if(parsedData.length == 0){
gs.addErrorMessage("Your error message here");
current.setAbortAction(true);
}
})(current, previous);
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-04-2023 04:37 AM
In my case, short description is one of the variables present in Multi row variable set.
Multirow variables set name is u_scrap_details.
i tried with both, it did not work for me when i am making any update on task
The script is not working for me