- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-27-2019 12:52 AM
Hi Team,
Need your assistance on below query.
I am trying to set a condition for notification to get triggered. I am now got stuck on how to use indexOf in below gliderecord query. So what i am trying to compare is, When the catalog is "Technical Catalog", notification should not be sent. Below is the script i have and it is triggering even for "Technical Catalog" which it should not.
Can anyone please help on this, what am i doing wrong?
answer = true;
var gr = new GlideRecord("sc_req_item");
gr.addQuery("request", current.sys_id);
gr.query();
if (gr.next()) {
if (gr.cat_item.sc_catalogs == indexOf(gs.getProperty("tc.item.catalogs.type")));
answer = false;
}
Regards,
Alok kumar sahu
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-27-2019 12:56 AM
HI,
If the value exist then it will return its position and if it does not then it will return -1.
So we have to compare that as well. Use below code:
if(gr.cat_item.sc_catalogs.indexOf(gs.getProperty("tc.item.catalogs.type")) >-1)
//THis means if the value in gr.cat_item.sc_catalogs is present in ur property then it will enter if loop.
Thanks,
Ashutosh

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-27-2019 12:54 AM
Try
if (gr.cat_item.sc_catalogs.indexOf(gs.getProperty("tc.item.catalogs.type"))!=-1);

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-27-2019 12:56 AM
HI,
If the value exist then it will return its position and if it does not then it will return -1.
So we have to compare that as well. Use below code:
if(gr.cat_item.sc_catalogs.indexOf(gs.getProperty("tc.item.catalogs.type")) >-1)
//THis means if the value in gr.cat_item.sc_catalogs is present in ur property then it will enter if loop.
Thanks,
Ashutosh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-27-2019 05:21 AM
Thank you Ashutosh 🙂

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-03-2019 01:29 AM
You are welcome bro.