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

Get the Parameters from URL

Kusuma2
Kilo Guru

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);

 

 

 

11 REPLIES 11

Syvo
Giga Guru

Hi Aj,

When the BR is executed, your URL is not the one you see in your browser anymore.

You'd better set the field with a catalog client script on load instead.

HTH
Sylvain

Thank you Sylvain,

I tried the clent script it is populating the text field and not the reference field.

function onLoad() {
//Type appr
var cat2 =getParmVal('sysparm_u_catalog_item');
alert(cat2);
//alert(cat2);
if(g_form.isNewRecord()){
alert("its is new record");g_form.setValue('u_incident', cat2);
g_form.setValue('short_description', cat2);
g_form.setValue('u_incident', cat.toString());

}


function getParmVal(name)
{
var url = document.URL.parseQuery();
if(url[name]){
return decodeURI(url[name]);
}
else{

return;
}
}

}

 

Aj,

Try this :

function onLoad() {
  var cat2 =getParmVal('sysparm_u_catalog_item');
  if(g_form.isNewRecord()){
  alert("its is new record");g_form.setValue('u_incident', cat2);
  g_form.setValue('short_description', cat2);
  g_form.setValue('u_incident', cat2.toString(), "my temp label");
}
 
 
function getParmVal(name) {
  var url = document.URL.parseQuery();
  if(url[name]){
     return decodeURI(url[name]);
  } else {
     return;
  }
}

 

 

 

Thank you for your quick response..still I am facing the isssue..

find_real_file.png