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

How to set scratchpad values into catalog client script

Rani11
Tera Expert

Hi All,

I am trying to access display business rule scratchpad values into catalog client script but it always shows undefined. Can anyone help here. I think there is some minor mistake.

Actually there is a record producer to create an incident. Whenever the incident is created via the record producer, it will automatically assigned to service desk. But there I am trying to build one exclude condition.

Like if particular ci is selected, the it should go to "Team A Group" instead service desk . Only for that particular condition the assignment group should changed. There is a hidden reference variable in the record producer to do this. The hidden field is "assignment_group". So in the catalog client script i am trying to call the scratchpad and set the value but the scratchpad value shows undefined always. Am i doing any mistake here? 

Is there anyway that scratchpad value to be called and used in catalog client script?

Display business rule on "Incident" Form :

 

find_real_file.png

Catalog Client Script which tried to call the scratchpad on  :

find_real_file.png

 

 

1 ACCEPTED SOLUTION

Hi,

Script Include: It should be client callable

var GetProperty = Class.create();
GetProperty.prototype = Object.extendsObject(AbstractAjaxProcessor, {

	getDetail: function(){
		
		return gs.getProperty('propertyName1') + '@' + gs.getProperty('propertyName2');
		
	},
	
    type: 'GetProperty'
});
function onChange(control, oldValue, newValue, isLoading) {
	if (isLoading || newValue == '') {
		return;
	}

	var ga = new GlideAjax('GetProperty');
	ga.addParam('sysparm_name', "getDetail");
	ga.getXMLAnswer(function(answer){
		if(answer != ''){
			var propertyValue1 = answer.split('@')[0];
			var propertyValue2 = answer.split('@')[1];

			// now compare

		}
	});
	//Type appropriate comment here, and begin script below

}

Regards
Ankur

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

View solution in original post

13 REPLIES 13

Hi,

Script Include: It should be client callable

var GetProperty = Class.create();
GetProperty.prototype = Object.extendsObject(AbstractAjaxProcessor, {

	getDetail: function(){
		
		return gs.getProperty('propertyName1') + '@' + gs.getProperty('propertyName2');
		
	},
	
    type: 'GetProperty'
});
function onChange(control, oldValue, newValue, isLoading) {
	if (isLoading || newValue == '') {
		return;
	}

	var ga = new GlideAjax('GetProperty');
	ga.addParam('sysparm_name', "getDetail");
	ga.getXMLAnswer(function(answer){
		if(answer != ''){
			var propertyValue1 = answer.split('@')[0];
			var propertyValue2 = answer.split('@')[1];

			// now compare

		}
	});
	//Type appropriate comment here, and begin script below

}

Regards
Ankur

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

Hi Ankur,

Thanks.

'If' condition below works fine, but I want to use an 'else' condition logic and not sure how to include that in this script? my 'else' within this answer function is unable to call another function, so I need to find a way to access variables propertyvalue1 and 2 outside the answer function... Is this possible in anyway?

find_real_file.png

 

Hi,

why to use else condition?

if you will always be having property as not empty then no need of else

the if part is used to handle and compare the property values

Regards
Ankur

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

@Ankur Bawiskar , How to set the values for multiple properties values in different variables?