Is it possible to use array in indexOf function?

Tarasingh26
Tera Expert

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

8 REPLIES 8

Anil Lande
Kilo Patron

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.

 

Please appreciate the efforts of community contributors by marking appropriate response as correct answer and helpful, this may help other community users to follow correct solution in future.
Thanks
Anil Lande

Aman Kumar S
Kilo Patron

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?

 

Best Regards
Aman Kumar

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.

Can you paste your code instead of screenshot will be easier to refer and edit

 

Best Regards
Aman Kumar