indexOf in Catalog Client Script
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-31-2018 05:23 AM
Does the indexOf in Catalog Client Script work? This should be simple but it seems to fail at this code. Neither side of the if statement executes and no other code after this executes. I see no errors in the log. What am I missing? It's correctly grabbing the display_name off the alm_asset table but the indexOf.......argh!
while (assettable.next())
{
thename = assettable.display_name;
alert("in asset check " + thename);
if (thename.indexOf("VMware") > -1 || thename.indexOf("VMWare") > -1 || thename.indexOf("Microsoft") > -1 )
{
countVirtual += 1;
}
else
{
countPhysial += 1;
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-31-2018 05:26 AM
Hi Stevem
Why not print thename.indexOf("VMware") and check what it is returning.
Mark Correct if this solves your issue and also hit Like and Helpful if you find my response worthy based on the impact.
Thanks
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-31-2018 05:30 AM
Hey Steve
There are two things what I can see
1) Use of GlideRecord in client scirpt, its not at all encouraged due to SYNC nature of this call, better way is to use GlideAjax
2) you should use assettable.fieldName.getDisplayValue() method to get the display name of the field
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-31-2018 05:34 AM
Oh my! I've been staring at this so long and never saw my spelling error. Great! It's fixed, it works.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-31-2018 06:00 AM
I have done this numerous time, typos !!!
Could you please go ahead and mark appropriate response as correct / helpful.