In catalog item if Selected asset tag has filewave entitlement need to visible another variable.

Servicenow de11
Tera Contributor

Hello,

 

I have a requirement that is in the catalog item one varaible ' Current Mac Computer Asset Tag' reference to cmdb_ci_computer table. If we select asset tag in Current Mac Computer Asset Tag and if that asset tag has filewave entitlement need to visible another variable New Mac Asset Tag. Can anyone help how to achieve this logic.

Servicenowde11_0-1698929313934.png

Filewave entitlements are existing in alm_entitlement_asset table and in the allocated field we need to enter the asset tag.

Tried the attched script but no working.

Servicenowde11_1-1698929546372.pngServicenowde11_2-1698929626833.png

 

 

1 ACCEPTED SOLUTION

Ankur Bawiskar
Tera Patron
Tera Patron

@Servicenow de11 

you cannot use current object.

you already have the selected record SysId in newValue

try this

function onChange(control, oldValue, newValue, isLoading, isTemplate) {
	if (isLoading) {
		return;
	}

	var gr = new GlideRecord("alm_entitlement_asset");
	gr.addQuery("allocated_to", newValue);
	gr.query();
	if (gr.hasNext()) {
		// show the other variable
	}
	else{
		// hide the other variable
	}

}

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

View solution in original post

1 REPLY 1

Ankur Bawiskar
Tera Patron
Tera Patron

@Servicenow de11 

you cannot use current object.

you already have the selected record SysId in newValue

try this

function onChange(control, oldValue, newValue, isLoading, isTemplate) {
	if (isLoading) {
		return;
	}

	var gr = new GlideRecord("alm_entitlement_asset");
	gr.addQuery("allocated_to", newValue);
	gr.query();
	if (gr.hasNext()) {
		// show the other variable
	}
	else{
		// hide the other variable
	}

}

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