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

Community Tip - Have a PTC product question you need answered fast? Chances are someone has asked it before. Learn about the community search. X

Passing result to property through subscription

svisveswaraiya
17-Peridot

Passing result to property through subscription

Hi,

How can I pass a result to a property of a Thing? 

I have a service which executes the stored procedure and returns a output string. I am calling this stored procedure through a subscription so whenever there is a data change in a tag in kepware, a row is updated into the sql. 

I wanted to set the service output string in the property of that Thing through a subscription whenever the tag value is changed.

PropertyPropertyserviceservicesubscriptionsubscription

 

Thanks,

Shalini V.

4 REPLIES 4

Hi @svisveswaraiya ,

 

have you defined the output of your service? I am not familiar with the old Thingworx layout but the question marks do not tell me the output type.

Additionally from what I know the service output needs to be stored to the variable result in your service. But I am also not familiar with this Execute syntax you use there.

Hi @svisveswaraiya ,

 

You are trying to map an infotable (output from service) to a string (property on Thing). To map your an entry from the first row, you result1.<ColumName> or choose your row with result[rowNumber].<ColumnName>: E.g result1[3].name

Hi @kornelius,

Thanks for your response. Should I change the property base type to infotable? Because after changing the subscription in a format you told its not setting any value in property.


var params = {
stationName: undefined /* STRING */,
skidNumber: undefined /* STRING */,
ToggleType: undefined /* STRING */
};

// result: INFOTABLE dataShape: "Navistar_ExecShipping_DS"
var result1 = me.Exec_TrackingData(params);

me.PRB415 = result1.ReturnResult

 

The ReturnResult is the column name of my infotable of Exec_TrackingData service.

Please tell me what I am missing.

 

Thanks,

Shalini V.

Hi @svisveswaraiya ,

 

The property base type in the PRB415 should stay as a string. In general it looks fine. As you are still facing issues, I recommend following:

To understand how to update properties, strip away the complexity first before working with a subscription:
1) Create an infotable with one row (e.g. as property, or in a service)

2) Write one field from the infotable into a string property on a thing (with a service)

Use the script logs to understand where your service fails.
Then apply it to your case. 

Top Tags