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

UI Action Redirect to Portal - Pass caller_id to portal form requested_for where default exists

jlaps
Kilo Sage

I am creating a context list ui action to create a hardware request from an incident record. I have it correctly opening a new tab to the correct form, but I am trying to pass the caller_id from the incident into the requested_for variable on the form. However, this form uses a default value for requested_for (whomever the current user is).

Is there a way to override this default value when doing this?

function do_it() {
var callersysid = g_form.getValue("caller_id");
var url = "https://elementcorp.service-now.com/esc?id=sc_cat_item&sys_id=df1e87ebdbdab5942620230bd39619d0" + "&sysparm_query=requested_for=" + callersysid;
top.window.open(url,);

}
3 REPLIES 3

Ankur Bawiskar
Tera Patron
Tera Patron

@jlaps 

use onLoad catalog client script to grab and populate.

It should work if you are not making that variable readonly at variable config level.

function onLoad() {
    var url = top.location.href;
    var caller = new URLSearchParams(url).get("sysparm_query");
    g_form.setValue('requestedForVariable', caller);
}

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

@jlaps 

Hope you are doing good.

Did my reply answer your question?

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

@jlaps 

Hope you are doing good.

Did my reply answer your question?

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