how to find if a script contains sub string
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-28-2020 11:54 PM
if we have two sub strings in string (GlideRecord ,Alert), how check the two sub strings
please write a program to check whether a string contains sub string
- Labels:
-
Incident Management

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-29-2020 12:30 AM
Hi there,
Not sure what you exactly mean. Can you give an example?
Something like below might work.
if(your_string.indexOf(other_string) != -1) {
...
}
If my answer helped you in any way, please then mark it as helpful.
Kind regards,
Mark
2020 ServiceNow Community MVP
2020 ServiceNow Developer MVP
---
LinkedIn
Community article list
Kind regards,
Mark Roethof
Independent ServiceNow Consultant
10x ServiceNow MVP
---
~444 Articles, Blogs, Videos, Podcasts, Share projects - Experiences from the field
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-29-2020 05:29 AM
hi expert!
How to check if a string contains sub string
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-29-2020 05:38 AM
if you are referring to searching for substring in some field of your table when you are doing GlideRecord then it should be like this
var gr = new GlideRecord('incident');
gr.addQuery('short_description', 'CONTAINS', 'test');
gr.query();
var count = gr.getRowCount();
gs.info(count);
Regards
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
11-29-2020 06:03 AM
Hello Ankur,
if i would say according to the recommendations using GlideRecord and alerts function in the client script is not best practices, so if it in case any client record contains both the above(gliderecord and alerts function)records it should show the like violation on custom UI Page(named it as 'show violation in my update set') table in that that case we consider gliderecord is one sub string and alert function is another sub string.we call them from separate 'upate set best practice' table.
so my question is how to write a script(in script include) to show them in violation table with their respective information.