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

Community Tip - New to the community? Learn how to post a question and get help from PTC and industry experts! X

Creating a Counter Strange Behavour

BryanK
14-Alexandrite

Creating a Counter Strange Behavour

I just wanted to share this as I have struggled with this for about a day now.

If anybody has a better way of doing this then please let me know.

I wanted to create a counter that increments a property value every time a Boolean value on a different property changes.

I am using a subscription to do this.

So this is what I had.

I then create an additional property that will keep the values.

I created the subscription on data change as such

I went in circles trying to figure out why its not working. then I had a look at the application logs.

Throwable Error Executing Event Handler for event Type.Thing:Entity.Quality_demo_data:Event.DataChange:Property.sorting-quality-demo_PLC1_conveyorOn : Execution error in service script [Quality_demo_data Event.DataChange:Property.sorting-quality-demo_PLC1_conveyorOn] : ReferenceError: "one" is not defined.

This made no sense to me at all so I tried with track two and three. And got similar errors.

So,

I thought could it be the name of the parameter?

I created another parameter called track1 and did the same thing.

And now its working.

I don't know if its a bug or just my level of jsp skills but there you have it.

2 REPLIES 2
dupatel
19-Tanzanite
(To:BryanK)

Bryan Kirchner​:  From the details it is not clear where exactly variable "one" been used as it is giving ReferenceError: "one" is not defined. I think the way you are assigning values in subscription could cause the issue. You can directly increment the property with something like this:

me.Counter = me.Counter +1;


Go to Me tab and use the property which you would like to increment in event of Boolean property change.

-Durgesh

BryanK
14-Alexandrite
(To:dupatel)

Hi Durgesh,

I did all of that. The Issue in the end was related to the name of the service ​because it had " - " in it.

As soon as I renamed the service to "track1" instead of "count-track-one"

it worked

Top Tags