Skip to main content
Jamal Ashraf
16-Pearl
Apr 5, 2024 4:57 AM UTC
Solved

How to store the state of variable in thingworx functions

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

 

Jamal Ashraf
16-Pearl
Apr 5, 2024 7:30 AM UTC

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

 

10 replies

Rocko
19-Tanzanite
Apr 5, 2024 6:11 AM UTC

To store and reuse the computed value, you can try

a) a Checkbox you make invisible

b) a Mashup parameter

c) a Session variable

Translate
Jamal Ashraf
16-Pearl
Apr 5, 2024 6:36 AM UTC

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?

Translate
Rocko
19-Tanzanite
Apr 5, 2024 6:43 AM UTC

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.

Translate