cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - When posting, your subject should be specific and summarize your question. Here are some additional tips on asking a great question. X

Using .includes() on a string never works

ague
12-Amethyst

Using .includes() on a string never works

Whenever I attempt to use the '.includes()' method on string in ThingWorx composer, I always get an error saying that the .includes method can not be found on the object. I even log the type of the variable that I am trying to edit, just to make sure it is in fact a string. And I still can not get around this.

 

Here's an example of what I'm talking about:

 

var myString = 'I am trying to debug some crazy ThingWorx issues';

var myBoolean = myString.includes('ThingWorx');

 

*the above code will throw the error:

'TypeError: Cannot find function includes in object I am trying to debug some crazy ThingWorx issues. (GetProcessPartID#22)]'

 

But if I log 'typeof myString', it will log 'string'.

 

What gives?!

ACCEPTED SOLUTION

Accepted Solutions

The .includes() function is not available.

Use .indexOf() instead:

(myString.indexOf('ThingWorx') != -1)

 

View solution in original post

4 REPLIES 4

The .includes() function is not available.

Use .indexOf() instead:

(myString.indexOf('ThingWorx') != -1)

 

ague
12-Amethyst
(To:Rick-Stanley)

Is there a rhyme or reason to why some javascript methods are available and others not? 

Yes, ThingWorx uses a custom version of Rhino for JavaScript processing in Services that conforms (with some exceptions) to the ECMAScript 5 specification.The ECMAScript 5 Specification can be found here.

ague
12-Amethyst
(To:Rick-Stanley)

Thank you! This is very helpful! 

Announcements

Top Tags