
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-23-2017 08:31 PM
Hi Team ,
I am storing a list of comma separated values in system property in the form of Json Format as shown below :
{"ticket":{"ListCI":"a,b,c,d,e,f"}}
I need to read this values in script includes . I have used the below code for the same :
var TypeCall = Class.create();
var iLookUpArray1 = [];
TypeCall.prototype = Object.extendsObject(global.AbstractAjaxProcessor, {
AutoTicketsCallType: function(){
var configItem = gs.getProperty("System Property Name");
var parser = new JSONParser();
var parsed = parser.parse(configItem);
var result = parsed.ticket.ListCI;
var gr1 = new GlideRecord('incident');
var encQy1 = 'cmdb_ci.nameIN'+result;
gr1.addQuery(encQy1);
gr1.query();
while(gr1.next()){
iLookUpArray1.push(gr1.getValue('sys_id'));
}
return iLookUpArray1;
},
type: 'TypeCall'
});
I see that comma separated values aren't read properly and I am not fetching any results . Could anyone let me know what has been missed in the above code ?
Thanks in advance .
Regards,
Ankitha
Solved! Go to Solution.
- Labels:
-
Scripting and Coding

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-24-2017 12:20 AM
Hi Ankitha,
Yes, properties do not get called from report condition builders.
You will have to take the ci name dynamically and then give it to the query.
There are some limitation to condition builder query such as gs.log don't work, gs.addInfoMessage won't work as well as gs.properties won't work.
So you have to give them or extract them in you script.
Thank you,
Ashutosh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-23-2017 08:57 PM
I think from either Helsinki or Istanbul you can use a different JSON parser, the code should look like:
var parsed = JSON.parse(configItem);

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-23-2017 09:08 PM
Hi Joe ,
Thanks for the response . Currently I am working in Geneva Version . However I tried the suggestion but no luck .
Regards,
Ankitha

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-23-2017 09:45 PM
HI Ankitha,
Please see below code and check what values you get. And here in properties please put actual CI names. Because if there is no incident related to a,b,c then no result. And plz define array after function declaration.
var TypeCall = Class.create();
TypeCall.prototype = Object.extendsObject(global.AbstractAjaxProcessor, {
AutoTicketsCallType: function(){
var iLookUpArray1 = [];
var configItem = gs.getProperty("testing");
var parser = new JSONParser();
gs.addInfoMessage(parser);
var parsed = parser.parse(configItem);
gs.addInfoMessage(parsed);
var result = parsed.ticket.ListCI;
gs.addInfoMessage(result);
var gr1 = new GlideRecord('incident');
var encQy1 = 'cmdb_ci.nameIN'+result;
gr1.addQuery(encQy1);
gr1.query();
while(gr1.next()){
iLookUpArray1.push(gr1.sys_id);
}
gs.addInfoMessage(iLookUpArray1);
return iLookUpArray1;
},
type: 'TypeCall'
});
Please try this, this is working for me.
Thank you,
Ashutosh

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-23-2017 09:54 PM
Hi Ashutosh ,
I have used actual CI's when I define in property . I am invoking this function in a report to fetch the incidents belonging to those CI's .
I have used the same code in Scheduled job and it works perfectly and gives the desired output . But when I use the same code in Script includes its not working . I am clueless for this . Is there any other which I need to follow to read the comma separated values from Json data in Script includes ?
Regards,
Ankitha