Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

UI Macro for populating CI related to the Requestor

SwiftTurtle
Tera Contributor

Hello!

I have a requirement to create a button on Requested Item form, next to the field Configuration Item that will show all CIs related to user in "Requested for" field. I reused functionality already working on Incident, but I am struggling with making it work on sc_req_item table.

 

The button is appearing on the form and showing right CIs, but when I click on the name - nothing happens. How to make it able to select the item from the pop up window?

 

Here is my code:

 

 

<?xml version="1.0" encoding="utf-8" ?>
<j:jelly trim="false" xmlns:j="jelly:core" xmlns:g="glide" xmlns:j2="null" xmlns:g2="null">
<j2:set var="jvar_n" value="getUserAssetsRi_${ref}"/>
<a id="${jvar_n}" onClick="getUserAssetsRi()" title="Lookup user assets" alt="Add me" tabindex="0" class="btn btn-default icon-hardware"></a>
	<script>
	function getUserAssetsRi() {
		var refurl = reflistOpenUrl('sc_req_item.cmdb_ci', 'sc_req_item.configuration_item', 'configuration_item', 'cmdb_ci', 'null', 'false', '');
		var url = 'assigned_to=' + g_form.getValue('requested_for');
		var refurlquery = refurl + url;
		popupOpenStandard(refurlquery, 'lookup');
	}
	</script>
</j:jelly>

 

 

Thanks in advance!

0 REPLIES 0