- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-22-2023 03:42 AM
Hi, I am trying to pass the value: contact_type=self-service^reassignment_count>=1^sys_created_on>javascript:gs.dateGenerate('2023-06-21','23:59:59')
and it is not working when called in script include.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-22-2023 06:27 AM
Hi @Mubashira ,
Since you are calling this script include from a report filter, gs.getProperty() will not work because the script include will be executed on the client side, please try to glide record the system property, try the code below:
var inc_GR = new GlideRecord("incident");
var propGR = new GlideRecord('sys_properties');
propGR.get('<SYSID of the system property>');
var encodedQuery = propGR.value;
inc_GR.addEncodedQuery(encodedQuery);
inc_GR.setLimit(500);
inc_GR.query();
while(inc_GR.next()){
var inc_sys_id = inc_GR.getValue("sys_id");
var inc_number = inc_GR.getDisplayValue("number");
//gs.print('Incident Sys_id: ' + inc_sys_id);
gs.info('Incident Number: ' + inc_number);
}
If my answer has helped with your question, please mark it as correct and helpful
Thanks!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-22-2023 03:58 AM
Hi @Mubashira,
Can you share your complete scripts here? It will helpful to find out the issues.
If my response helps to solve your issue. Kindly mark it as helpful & correct. It will be helpful for future readers.
Thanks,
Sagar Pagar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-22-2023 04:21 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-22-2023 05:44 AM
Hi @Mubashira,
Try this updated scripts.
var Test_Incorrect_Incident_Assignment_MQ = Class.create();
Test_Incorrect_Incident_Assignment_MQ.prototype = {
initialize: function() {},
getTest_Incorrect_Incident_Assignment_MQ: function() {
// Objective is to get the incidents for reassignment count > 1 and 'Global Service Desk' is assigned 2 or more times.
var sysidArr = [];
//var incorrectInc = gs.getProperty('Test.Encoded.Query.A.MQ').toString();
//var incorrectGSDInc = gs.getProperty('Test.Encoded.Query.B.MQ').toString();
//var inccount = gs.getProperty('incorrect_inc_limit_smo');
var filterQuery = gs.getProperty("Test.Encoded.Query.A.MQ");
var inc_GR = new GlideRecord("incident");
//inc_GR.addEncodedQuery("contact_type=self-service^reassignment_count>=1^sys_created_on>javascript:gs.dateGenerate('2023-06-21','23:59:59')");
inc_GR.addEncodedQuery(filterQuery);
inc_GR.setLimit(500);
inc_GR.query();
while (inc_GR.next()) {
var inc_sys_id = inc_GR.getUniqueValue();
var inc_number = inc_GR.getDisplayValue("number");
sysidArr.push(inc_sys_id);
//gs.print('Incident Sys_id: ' + inc_sys_id);
//gs.info('Incident Number: ' + inc_number);
}
return sys_idIN + sysidArr;
}
};
Call in reports:
javascript: Test_Incorrect_Incident_Assignment_MQ().getTest_Incorrect_Incident_Assignment_MQ();
If my response helps to solve your issue. Kindly mark it as helpful & correct. It will be helpful for future readers.
Thanks,
Sagar Pagar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-22-2023 07:04 AM
Hi Sagar,
The code below is working correctly when I use the encoded query within the script but not when I get the value by calling system properties.