Skip to main content
16-Pearl
April 5, 2024
Solved

How to store the state of variable in thingworx functions

  • April 5, 2024
  • 1 reply
  • 3109 views

Is there any way that i can store the state of this parameter in expression. I dont have anything to bind it from my mashup. So in the screenshot you can see that i have bool which has default value true and i just want it to change every time i use this function. For example I change the state to false then again next time i evaluate i turn it into true

 

Jamal8548_0-1712292862465.png

 

Best answer by MA8731174

Hi @RadekIOT  @Rocko , Thank you both of you. Its working now. The problem was that when i uncomment the console.log it does not work... I just commented it out and now everything is working perfectly fine! 🙂 Sometimes Thingworx is a bit different haha..

Jamal8548_0-1712302190297.png

 

1 reply

Rocko
19-Tanzanite
April 5, 2024

To store and reuse the computed value, you can try

a) a Checkbox you make invisible

b) a Mashup parameter

c) a Session variable

MA873117416-PearlAuthor
16-Pearl
April 5, 2024

I create an expression 

Jamal8548_0-1712298747344.png

 

Expression detials

 

Jamal8548_1-1712298786634.png

I have created a mashup parameter named status. Its a checkbox and i have selected it with true and i change it everytime i run this expression so i change it to true and false

 

Jamal8548_2-1712298915348.png

 

mashup parameter

Jamal8548_3-1712298934719.png

 

Now the problem is i get in console.log no value neither true nor false. it shows me empty space in console.log. can you see whats an issue?

Rocko
19-Tanzanite
April 5, 2024

Maybe try to assign a value when opening the mashup first to debug. You can also log something on the event of statusChanged which should be there on the mashup.

It can be it does not work with mashup parameters.  Options a) and c) are sure shots though.