Can a UI action be set to open a specific catalog item?

Brett Watson
Tera Contributor

Kia ora Community,

I've seen posts explaining how to set a ui action to create a new incident, with script along the lines of:

var inc = new GlideRecord('incident'); inc.newRecord(); inc.short_description = current.getValue('short_description); inc.insert();

 

I'm wanting to do something similar but would like the UI Action to:

a) open a specific catalog item called 'Request for SAP People' as well as

b) pre-populate some of the fields in the opened catalog item.

 

I've seen multiple posts (like this one - https://community.servicenow.com/community?id=community_question&sys_id=c2e89e4ddbeaf38023f4a345ca961902) explaining how to set the UI Action to open a url but that method doesn't allow me to pre-populate field values.

 

Does anyone know if what I'm trying to do is possible?

 

Thanks in advance.

- Brett

5 REPLIES 5

Allen Andreas
Administrator
Administrator

Hello,

Please give more information. Do you mean you want them to use a UI Action to go to a specific catalog item form...with some fields pre-populated...or do you mean order a catalog item with some fields pre-filled in.

Unfortunately, it's not clear and you gave 2 examples of opposite things.

Please mark reply Helpful/Correct, if applicable. Thanks!


Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!

Kia ora Allen,

Thanks for the quick response, and sorry for the confusion!

My ideal would be that they click and a new window opens with the Request for SAP People catalog item and some of the Request for SAP People catalog item fields are pre-filled in with values but the item is not submitted, so the user can fill in other fields (whose value can't be derived).

But, if above is not possible and it is possible for clicking to create/submit the Request for SAP People and fill in the fields on the Request for SAP People that would be workable solution too 😃

Hope that clarifies and thanks again

- Brett

Rogers Cadenhe1
Giga Guru

You can redirect to a form in a UI action and prepopulate some fields by using the sysparm_query URL parameter to set those values.

Here's example UI action script code that opens a new Incident form with the Short Description and Caller fields set by the URL:

var uri = gs.getProperty('glide.servlet.uri');
var url = uri + 'incident.do?sys_id=-1&sysparm_query=short_description=' + current.short_description + '^caller_id=' + gs.getUserID();
action.setRedirectURL(url);

You can prepopulate multiple fields by separating them with "^" characters in the sysparm_query parameter value.

How can de do same thing for record producer variables? and ideas will be helpful.

Thanks