Get the Parameters from URL
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-22-2018 01:45 AM
Hi Gurus,
I have a requirement to populate the field on the record producer when a record producer is created from incident.
UI page Client redirecting to Record Producer on selection:
Its working fine.
Now I want to get the sys_id present in the url to Record Producer Reference Field.
I have written the business Rule(before/after insert) to get the parameter value from the url and update the field but it showing me undefined.
(function executeRule(current, previous /*null when async*/) {
// Add your code here
var cat = gs.action.getGlideURI().getMap().get('u_catalog_item');
gs.addInfoMessage(cat);
//var cat1 =gs.action.getGlideURI().indexOf('sysparm_u_catalog_item');
var cat2=RP.getParameterValue('sysparm_u_catalog_item');
//gs.addInfoMessage(cat1);
gs.addInfoMessage(cat2);
if(current.isNewRecord()){
gs.addInfoMessage("its is new record");
//current.u_incident=cat;
current.u_incident=cat1;
// current.u_incident=cat.getDisplayValue;
// current.u_incident=cat1.getDisplayValue;
//current.short_description= cat;
current.short_description= cat1;
current.update();
// g_form.setValue('u_incident', cat.toString());
}
})(current, previous);

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-22-2018 04:04 AM
Aj,
Your script is working as expected. The u_incident is a reference field. If you want to show the display value, you should pass it as a second parameter in your url.
function onLoad() {
var cat2Label = getParmVal('sysparm_u_catalog_item_label');
var cat2ID = getParmVal('sysparm_u_catalog_item_id');
if(g_form.isNewRecord()){
g_form.setValue('short_description', cat2Label);
g_form.setValue('u_incident', cat2ID, cat2Label);
}
function getParmVal(name) {
var url = document.URL.parseQuery();
if(url[name]){
return decodeURI(url[name]);
} else {
return;
}
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-22-2018 04:17 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-22-2018 05:26 AM
Aj,
Reading you client script, I don't really understand what you are trying to do.
Let me know if I got it right.
- A user is looking at an incident
- He clicks on a button (?) to open a dialog box
- In this box, he can choose to open a new incident
- The incident record producer is opened and the original incident is referenced in the u_incident field
It feels like you're mixing up the sys id of the record producer you're trying to use and the current incident id.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-22-2018 05:47 AM
Yes You got it.
a New dialog box opens on incident form and in that box I have a choice list field with choices(Record producer, CATALOG ITEM).
Based upon the selection it is redirecting. After getting redirected I would like to copy the incident number on the new Redirect form field(on record producer custom field).
How can I achieve this..is my approach not correctto solution not correct?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-22-2018 06:01 AM
There is a problem with how you are trying to achieve this. What you are doing right now is opening a new Record producer record and initializing some fields.
What you want is using a record producer to initialize the creation of a new incident (right?).
You first need to know which record producer you have to open. Open this list to see the record producers that can produce an incident: /sc_cat_item_producer_list.do?sysparm_query=table_name%3Dincident&sysparm_list_mode=grid
The url you will open then is not directly on sc_cat_item_producer but rather /com.glideapp.servicecatalog_cat_item_view.do?v=1&sysparm_id=3f1dd0320a0a0b99000a53f7604a2ef9 (for example for "Create Incident").
If you want to add fields to this record producer, you're going to add variables, just like you do with a catalog item.