RITM form has "Requested For" field as blank even if I fill the same in service portal form.

Pritish Moharan
Kilo Contributor

RITM form has "Requested For" field as blank even if I fill the same in service portal form (Catalog item form).Please refer my attached snippets.

 

For "Requested For", I am using reference type variable

7 REPLIES 7

Service_RNow
Mega Sage

HI,

please use default value requester variable,

javascript:gs.getUserID()

find_real_file.png

Please mark reply as Helpful/Correct, if applicable. Thanks!

 

This would auto populate the value in the form, but will not map it to the field on submit.

Hi Santhana,

Please write a Business rule On the sc_request table

After, insert, Update

Code:

function executeRule(current, previous /*null when async*/) {

var request = new GlideRecord("sc_req_item");
if(request.get('request',current.sys_id)){
var req_for = request.variables.u_requested_for;
if(req_for != undefined || req_for == ''){
current.requested_for = req_for;
}
}

})(current, previous);

Please mark reply as Helpful/Correct, if applicable. Thanks!

Santhana Rajhan
Mega Sage

Since this is a requested item, mapping to the field doesn't happen automatically. What we have done in our system is, we added a business rule.

Business Rule: After - On Insert

You could try script something like this.

(function executeRule(current, previous /*null when async*/) {
	
	//Get Location and Requested for values from Catalog item and populate on Requested Item.
	var user = current.variables.requested_for;
	//var location = current.variables.location;
	//var requester = current.variables.requester;
	//current.location.setValue(location); // Populate Location
	
	if(user){
		current.request.requested_for.setValue(user);
	}
	else{
		current.request.requested_for.setValue(requester);
	}
	current.update();
	
	
})(current, previous);