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.

Add reference field to sysparm value in Navigation URL

cgedney
Giga Guru

I'm trying to update a business rule on the Call Form:

----------------------------------------------------------------------------------------

var reqFor = current.caller;
var contactType = current.contact_type;
var location = current.caller.location;
var reqItem = current.request_item;
var appName = current.u_application_name;
var comments = "NEW_CALL_REF:" + current.sys_id + " " + current.description;

var url = "com.glideapp.servicecatalog_cat_item_view.do?sysparm_id=" + reqItem
+ "&sysparm_requested_for=" + GlideStringUtil.urlEncode(reqFor)
+ "&sysparm_location=" + GlideStringUtil.urlEncode(location)
+ "&sysparm_Application_Name=" + appName
+ "&sysparm_special_instructions=" + GlideStringUtil.urlEncode(comments)
+ "&sysparm_stack=" + current.getLink()
+ "&sysparm_contact_type=" + contactType;
action.setRedirectURL(url);
current.isNavigateToCatalog = true;

----------------------------------------------------------------------------------------

where current.u_application_name is a reference to the application (cmdb_ci_appl). I'm trying to get it to populate the application name field on the request form.

Any help is very much appreciated.

Charles

1 ACCEPTED SOLUTION

Tony Chatfield1
Kilo Patron

Hi,
if current.u_application_name is a reference field then you probabaly need to populate the records sys_id, so current.u_application_name.sys_id or current.u_application_name.toString() should give you the results you need.
Otherwise if the target field is a string I think you may want current.u_application_name.getDisplayName() or current.u_application_name.getDisplayValue() depending on source data type.

View solution in original post

4 REPLIES 4

Tony Chatfield1
Kilo Patron

Hi,
if current.u_application_name is a reference field then you probabaly need to populate the records sys_id, so current.u_application_name.sys_id or current.u_application_name.toString() should give you the results you need.
Otherwise if the target field is a string I think you may want current.u_application_name.getDisplayName() or current.u_application_name.getDisplayValue() depending on source data type.

Chaitanya Redd5
Tera Guru

Could you please give a try using below code

current.u_application_name.getUniqueValue();

Kindly mark my answer as Correct and Helpful based on the Impact

DrewW
Mega Sage

I seam to remember that there are two parts to this.  There is the part that you are looking at that sends the data over then there is a part that runs on the request that pulls the data out and populates it into the items.

 

cgedney
Giga Guru

So I am able to get it to populate after the user selects the application name and submits it on the request. The problem I am having is transferring it from the call form to the request form. I found a business rule on the request form, but that doesn't fire until the user submits the request form. I found one on the call record (which is the one I have above in the question), but that one doesn't seem to be sending the reference. I tried all of the suggestions, but I am still unable to get it to fill in on the request form. I believe Drew is correct that there is a piece I am missing on the request form that pulls the sysparm values and puts them on the form. Does anyone know where that would be?

Thank you,

Charles