Skip to main content
1-Visitor
June 14, 2021
Question

Expression won't evaluate

  • June 14, 2021
  • 3 replies
  • 3832 views

I am using ThingWorx 8.5.3-b123 and I am trying to use an expression to get the user's local timezone offset from UTC. I created an expression with no parameters and have it evaluate the following for testing:

 

 

Output = 4;

 

 

The output is bound to a parameter of a thing service and the "Changed" property of the expression is bound to evaluate the service. I then bound the mashup "Loaded" to evaluate the expression. I left auto evaluate and fire on first value unchecked, and I set data change type to always. For some reason, I still never get a value in the parameter of my service! I get errors saying JSON does not allow non-finite numbers. If I set a default value to this parameter of my service, all works well but it's obviously not a solution. Anybody have any ideas? Thanks

3 replies

15-Moonstone
June 15, 2021

@JJ_9237608 : Have you tried binding the output to a value display widget and checked its value? Would be great if you can provide entities for replicating your issue.

1-Visitor
June 16, 2021

I bound it to a label widget and it showed 4, as appropriate. I discovered that the mashup preview button is actually functioning perfectly whereas the live mashup is not. I am sure that I'm saving properly, so I really can't figure why it isn't publishing my changes on this mashup. When I make other changes like datasets or services, it shows up just fine. Attached below are some screenshots of the preview and real mashup.

15-Moonstone
June 16, 2021

Hi,

 

Expression sometimes behave differently. I am doing same what you have explained.

On mashup load calling expression, on change of expression I am calling a status message and output of expression is going in to status message. It is behaving ok. 

 

I believe you need to change the body of expression to output=4 instead of Output=4.

Find attached.

 

Regards

Shyam

1-Visitor
June 16, 2021

It seems that the expression is working now, but as I wrote above to the other commenter, it seems like the mashup isn't updating now. Any ideas?

15-Moonstone
June 16, 2021

Sorry I didn't get you what you are saying.

 

Regards

Shyam

12-Amethyst
August 10, 2021

Hi @JJ_9237608 ,

 

Expression does not need "output". If you want your expression to output the number 4, the only thing you need in the code is "4" without the quotes, obviously.  That's why the "non-finite numbers" error.

 

BR,

Gabriel