Reference Qualifier on a Change Record to display the linked Problem

Arijit Saikia
Tera Contributor

Hi,

I am trying to display a Problem Record that has been linked to a change on the Change_Request form.

I have created a new reference field on the Change_request form and have created a Dynamic Reference Qualifier.

The newly created Column name in the Change_request form is u_prb

The Script in the Dynamic Filter is new DynamicPrbUtility().prRecord();

The Script Inlcude is :

 

var DynamicPrbUtility = Class.create();
DynamicPrbUtility.prototype = {
initialize: function() {
},
prRecord: function()
{

var gr = new GlideRecord('problem');
gr.addQuery('rfc', current.sys_id);
if(gr.next())
{
return number;
}
},
type: 'DynamicPrbUtility'
};


However, the u_prb field doesn't get populated even though I have done the linkage to the Change_request from the Problem form. What am I missing?

1 ACCEPTED SOLUTION

So looks like you have a dynamic filter on the reference field. You are not actually setting the field value.

To set the field value, you may need a before business rule on the problem record instead with below script. This will update the field when you link the change to problem.

 

var gr = new GlideRecord('change_request');
gr.addQuery('sys_id', current.rfc);
if(gr.next())
{
gr.u_prb = current.sys_id;

gr.update();
}


Please mark this response as correct or helpful if it assisted you with your question.

View solution in original post

3 REPLIES 3

SanjivMeher
Kilo Patron
Kilo Patron

Fix the script. You need to return the sysid i guess

 

var DynamicPrbUtility = Class.create();
DynamicPrbUtility.prototype = {
initialize: function() {
},
prRecord: function()
{

var gr = new GlideRecord('problem');
gr.addQuery('rfc', current.sys_id);
if(gr.next())
{
return gr.sys_id;
}
},
type: 'DynamicPrbUtility'
};


Please mark this response as correct or helpful if it assisted you with your question.

Thanks Sanjiv, I tried your recommendation, still not returning the number.

I am attaching the xml which shows the parent:

<parent display_value="PRB0000007">9d3a266ac6112287004e37fb2ceb0133</parent>

So looks like you have a dynamic filter on the reference field. You are not actually setting the field value.

To set the field value, you may need a before business rule on the problem record instead with below script. This will update the field when you link the change to problem.

 

var gr = new GlideRecord('change_request');
gr.addQuery('sys_id', current.rfc);
if(gr.next())
{
gr.u_prb = current.sys_id;

gr.update();
}


Please mark this response as correct or helpful if it assisted you with your question.