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

@Mishu 

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);
Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

@Ankur Bawiskar ..yes short_justification is a variable within MRVS

No l̥uck with the script though! : (

 

@Ankur Bawiskar 

it is not entering to below line 

if(parsedData[i].short_justification == '')

 

@Mishu Please Change the line to

 

if(parsedData[i].short_justification == '' || parsedData[i].short_justification==null)

@Mishu 

are you sure the variable name is correct?

did you print the json string in logs?

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