Skip to main content
3-Newcomer
November 30, 2023
Solved

SetPropertyVTQ not working with JAVA SDK

  • November 30, 2023
  • 1 reply
  • 1317 views

I am trying to set a value of a property using SETPROPERTYVTQ by writing code in the service of my thing. I will an API and after the response of the API i will set the value of a particular property. Here is the code I am using:
VTQ vtq = new VTQ();
vtq.setValue(String(events[4].machineCode));
vtq.setTime(new DateTime());
vtq.setQuality(QualityStatus.GOOD);
base.setPropertyVTQ(me.ReasonCode, vtq,true);
While executing the code I am getting the error as: Message :: ReferenceError: "VTQ" is not defined. - See Script Error Log for more details.

Best answer by smainente
  1. You cannot use a ThingWorx Java API direcly from Script Service.
  2. To set the VTQ of a property from a Script Service, you can use the SetPropertyValues service on the Thing.
    Snippet:  https://community.ptc.com/t5/ThingWorx-Developers/How-to-update-all-Thing-s-properties-from-script/m-p/512242#M9133%3Fsource=search

1 reply

17-Peridot
November 30, 2023

@NM_10812832 ,

 

Are you using the Java Edge SDK or the Java Extension SDK?

 

-Nick

3-Newcomer
December 1, 2023

Basically I am writing this code in one of the service in a thing which is responsible for getting data from an API. SO I am writing the code in Javascript inside service. In this JS I am trying to get a logic for setPropertyVTQ. I think it is Java Edge SDK.

smainente16-PearlAnswer
16-Pearl
December 1, 2023
  1. You cannot use a ThingWorx Java API direcly from Script Service.
  2. To set the VTQ of a property from a Script Service, you can use the SetPropertyValues service on the Thing.
    Snippet:  https://community.ptc.com/t5/ThingWorx-Developers/How-to-update-all-Thing-s-properties-from-script/m-p/512242#M9133%3Fsource=search