Is it possible to use array in indexOf function?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-04-2023 04:20 AM - edited 09-04-2023 04:21 AM
Hi All,
I have string nm, I need to check if nm string contains any element of array of substring. I am trying to achieve it using highlighted code in attached screenshot but it is not working. If anyone implemented this type of requirement, please help me in this.
Thanks,
Tara Singh

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-04-2023 09:03 AM
Hi,
Can you please share an example ?
what would be the value stored in 'nm' and what value you are getting in array?
Put some log statements and see what values each variable containing in all iterations.
From where I see it the script is not self explanatory and we are not able to guess what exactly it is doing.
Thanks
Anil Lande

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-04-2023 09:30 AM
Hi @Tarasingh26 ,
Few things about your code, if you are using getValue() there is no need to to use toString() with it, getValue itself fetches string type value.
By your indexOf logic, it seems you are searching if the variable nm contains the array element, is that what you intend on checking?
Aman Kumar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-04-2023 10:22 AM
That's correct Aman. nm is a string and tArray is array of substrings . I want to see if string nm contains any of substring from tArray array . If found then want to set status field from tArray elements to value 2.
Want to set array element value status as 2 Arry[i]=gr.setValue('status', 2) something like this. But I am struggling the right syntax to use.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-04-2023 10:25 AM
Can you paste your code instead of screenshot will be easier to refer and edit
Aman Kumar