sysparm_processing_hint in Create Request UI Action

kungfuu72
Giga Expert

On the Incident table, there is a particular out-of-box UI Action that I'm going to modify to be more intuitive and useful for us.

The UI Action is called Create Request.

 

Out-of-box Code:

//Update saves incidents before going to the catalog homepage
current.update();
gs.addInfoMessage('You will need to navigate back to incident ' + current.number + ' upon request completion');


var url = "catalog_home.do?sysparm_view=catalog_default&sysparm_processing_hint=setfield:request.parent="
url += current.sys_id;


action.setRedirectURL(url);


 

 

What is interesting about this simple UI Action is the sysparm_processing_hint in the URL. This URL parameter is setting the parent field of the Request record to the Incident (sc_request).

 

My question is whether you can set other fields on other tables OR multiple fields on a new/existing record

 

For example:

 

Instead of going to the Service Catalog, my redirect will go to a new Requested Item (sc_req_item) form where the:

 

var url = "sc_req_item.do?sysparm_processing_hint=setfield:sc_req_item.assigned_to=";
url += current.assigned_to.sys_id;


 

 

I'm going to test this out, but does anyone have anymore information about the sysparm_processing_hint URL parameter? I was not able to find anything about it on the forums or the Wiki... ?

 

Mark Stanger (Crossfuze)

Maybe a good use-case in a Crossfuze Solutions if this URL parameter turns out to be extensive.

9 REPLIES 9

I was not able to successfully doing any immediate surface testing with the sysparm_processing_hint parameter, but instead used the solution from Mark as published on ServiceNow Guru:



» How to Parse Parameters from a URL in ServiceNow



From this I was able to pass my values from a record through a link to a Catalog Item form and have it populated before submission.



I would just say that in doing the above solution, keep in mind that a URL max length is around 2,000 characters.



I have not tested the above solution in Fuji either, as our instances are still on Dublin (scheduled to upgrade shortly though), so I will be looking to make sure this functionality already implemented does not break when we upgrade.


rsanon
Tera Contributor

Thanks! Can you provide a sample of what it would look like, copying a field from the from to a variable on the catalog item?



I tried something, like this and it didn't work



var url = "catalog_home.do?sysparm_view=catalog_default&sysparm_query=u_caller=${variable_pool.on_behalf_of.sys_id}";


I'm not too certain I understand what you're asking for, but here is an example of our case:



We want to forward to a specific catalog item with information from the current record that is displayed.


We create a UI Action (not a client-side UI Action).



To build the response redirect we build out our URL with whichever fields we want to use (up to a 2,000 character limit).



// URL to be generated to forward to a catalog item.


var url = 'com.glideapp.servicecatalog_cat_item_view.do?sysparm_id=[catalog_item sys_id]'; // sys_id of the catalog item you want to forward to.



// Adding in the URL parameters.


url += '&sysparm_caller_id=' + escape(current.[field_name]); // field name may be something like caller_id in your case.



response.sendRedirect(url);



On the Catalog Item, we create an onLoad Catalog Client Script:


// Populate the variables with the parameters passed in the URL


// Uses the "getParmVal()" function defined in a separate Catalog Client Script.



function onLoad() {


  var caller = getParmVal('sysparm_caller_id');



  // Set Caller variable.


  if(caller) {


            g_form.setValue('caller', caller);


  }


}



The getParmVal function is in a separate onLoad client script that is also on the Catalog Item (or a Variable set the Catalog Item has).


// Function attached to a variable set that is included on all our Catalog items to mimic a "global" presence.


// Parses window URL for any defined custom sysparm_[parameter name] values.


function getParmVal(name) {


  name = name.replace(/[\[]/, '\\\[').replace(/[\]]/, '\\\]');


  var regexS = '[\\?&]' + name + '=([^&#]*)';


  var regex = new RegExp(regexS);


  var results = regex.exec(window.location.href);



  if(results == null) {


            return;


  }


  else {


            return unescape(results[1]);


  }


}



Just a quick example here. Keep in my mind, that this is simplified. My actual code has error checks and I'm actually doing this through a UI page that passes the values through the processing script, so in this example I am cutting all that out and instead using a UI Action that will run server code instead.


Brian Lancaster
Tera Sage

Did you ever get an answer to this?  There is a similar UI Action for creating a Standard Change.  However I need to do it from an incident task and service catalog task so I have a custom field that need to be populated with the reference to the change number.

To open a record form with preset values, you can use sysparm_query parameter as described here:

https://docs.servicenow.com/bundle/newyork-platform-user-interface/page/use/navigation/reference/r_NavigatingByURLExamples.html

To set values on a record generated via a record producer, you can use sysparm_processing_hint parameter documented here:

https://docs.servicenow.com/bundle/newyork-it-service-management/page/product/service-catalog-management/reference/service-catalog-parameters.html