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 05:18 AM
then update as this
I assume short_justification is variable within MRVS
(function executeRule(current, previous /*null when async*/) {
// Add your code here
var parsedData = JSON.parse(current.variables.u_scrap_details);
var isEmpty = false;
for(var i=0;i<parsedData.length;i++){
if(parsedData[i].short_justification == ''){
isEmpty = true;
break;
}
}
if(isEmpty){
gs.addErrorMessage("Your error message here");
current.setAbortAction(true);
}
})(current, previous);
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 05:40 AM - edited ‎08-04-2023 05:48 AM
@Ankur Bawiskar ..yes short_justification is a variable within MRVS
No l̥uck with the script though! : (
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-04-2023 05:58 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-04-2023 06:16 AM
@Mishu Please Change the line to
if(parsedData[i].short_justification == '' || parsedData[i].short_justification==null)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-04-2023 06:43 AM
are you sure the variable name is correct?
did you print the json string in logs?
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader