The CreatorCon Call for Content is officially open! Get started here.

When variable empty in MRVS at Task Level, Abort task submission.

Mishu
Tera Expert

At task level, how to abort form submission, when a few of the variables are empty in Multi Row variable set?

14 REPLIES 14

Ankur Bawiskar
Tera Patron
Tera Patron

@Mishu 

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?

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

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 ?

@Mishu 

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.

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

@Ankur Bawiskar 

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