- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-29-2018 06:29 AM
Hello Experts,
I'm struggling with the development of a reference qualifier on the Call table (new_call).
When a call record is submitted, it may create a incident if the call type selected is incident. During the creation of the incident, a few fields are copied from the call record to the incident record, one of them being the email.
The business requirement is that when a second call is created, we should be able to link it to an existing incident. I'm trying to put a reference qualifier on a "Link to Incident" Reference field so that only Incidents with a corresponding email address will show.
I'm trying this by copying/adapting what is done on the Model ID on the configuration item form (https://docs.servicenow.com/bundle/jakarta-platform-administration/page/script/server-scripting/concept/c_ReferenceQualifiers.html).
I don't know if this is the right approach, as it is my 1st time handling complex reference qualifier.
I have created a Dynamic Filter option called "Incident Email Qualifier", which calls DDCallUtils().showRelatedInc(current). I have also configured the ref qualifier as dynamic and selected the Incident Email Qualifier.
The Script include:
var DDCallRefQual = Class.create();
DDCallRefQual.prototype = {
initialize: function() {
},
showRelatedInc: function(call){
var refQual = 'u_temporary_emailISEMPTY';
var callEmail = this.getValue(call.u_temporary_email);
var gr = new GlideRecord('incident');
gr.addQuery('u_task_temporary_email', callEmail);
gr.Query();
if(gr.next()){
refQual += 'ANDu_temporary_emailLIKE' + gr.u_task_temporary_email;
}
return refQual;
},
type: 'DDCallRefQual'
};
Presently the reference field doesn't filter anything, so I'm pretty sure I'm missing something 🙂
Any help would be appreciated !
Thanks
Florian
Solved! Go to Solution.
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-29-2018 09:30 AM
Thanks a lot for your answer Marc,
My Ref Qualifier was indeed not implemented correctly, I was never able to execute my Script include even with a simple query.
That sent me on another path, I was actualy able to do this quite simpler with a advanced ref qualifier, forgetting about dynamic ref qualifier.
On my "Linked to Incident" field on new_call table, I added the advanced ref qualifier below:
javascript: 'u_task_temporary_email='+current.u_temporary_email
where u_task_temporary_email is the email field on incident, and u_temporary_email my field on call.
Works like a charm, I don't know why I wanted to do something so complicated 🙂
Thanks again for getting me to test this correctly !
Regards
Florian
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-29-2018 08:26 AM
Hi,
First, you should check if the reference qualifier is correctly implemented.
To do so, replace the content of your script with something hardcoded like number IS INC0000001 and see if it works well
(replace INC0000001 with an existing incident number so you get 1 result)
If it works, then the issue is the script.
I already see something strange with "this" in your script:
var callEmail = this.getValue(call.u_temporary_email);
Couldn't you just do:
gr.addQuery('u_task_temporary_email', call.u_temporary_email);
One last thing:
you put refQual += AND.......
shouldn't it be an OR ?
Regards,
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-29-2018 09:30 AM
Thanks a lot for your answer Marc,
My Ref Qualifier was indeed not implemented correctly, I was never able to execute my Script include even with a simple query.
That sent me on another path, I was actualy able to do this quite simpler with a advanced ref qualifier, forgetting about dynamic ref qualifier.
On my "Linked to Incident" field on new_call table, I added the advanced ref qualifier below:
javascript: 'u_task_temporary_email='+current.u_temporary_email
where u_task_temporary_email is the email field on incident, and u_temporary_email my field on call.
Works like a charm, I don't know why I wanted to do something so complicated 🙂
Thanks again for getting me to test this correctly !
Regards
Florian