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

Community Tip - Did you know you can set a signature that will be added to all your posts? Set it here! X

GetNamedPropertyValues service throwing error

rvuta1
1-Newbie

GetNamedPropertyValues service throwing error

Hi everyone,

I am trying to get property values of thing by passing property names dynamically.

Using GetNamedPropertyValues service to achieve this.

I am passing two column names to service,but its considering one more empty column and throwing error like below.

Wrapped com.thingworx.common.exceptions.InvalidRequestException: Property [null] not found in [Plant 32] Cause: Property [null] not found in [Plant 32]


Plant 32 is my "Thing" name


sharing my code snippet ,Please suggest me where I am doing wrong.

var params_1 = {

  infoTableName : "InfoTable",

  dataShapeName : "ProdInfoColmn_DS"

};

// CreateInfoTableFromDataShape(infoTableName:STRING("InfoTable"), dataShapeName:STRING):INFOTABLE(ProdInfoColmn_DS)

var result_info = Resources["InfoTableFunctions"].CreateInfoTableFromDataShape(params_1);

   var  newRow = new Object();

    newRow.TargetQuantity = "TargetProduction_A";

    newRow.ActualQuantity = "Production_A";

result_info.AddRow(newRow);

/*var fieldName = null;

result_info.RemoveField(fieldName);*/

var params = {

  propertyNames: result_info /* INFOTABLE */

};

var result = Things["Plant 32"].GetNamedPropertyValues(params);

Appreciate your help..

Regards,

Rajee.

Message was edited by: Sushant Pandey

1 ACCEPTED SOLUTION

Accepted Solutions
supandey
19-Tanzanite
(To:supandey)

Here's a quick demo

1. Created a Infotable with DS that has filed name and description, of course you don't have to create a property with Infotable like this you can simply create that in your script

2. Here's how my service looks like :

var params = {

  propertyNames: me.PropertyForGetPropertyValues /* INFOTABLE */

};

// result: INFOTABLE dataShape: "undefined"

var result = me.GetNamedPropertyValues(params);

3. Do note that my returned output contains the DS which matches with the required Output for my data, like so

Hope this will help.

View solution in original post

10 REPLIES 10
supandey
19-Tanzanite
(To:rvuta1)

Hi Raji, how does the DataShape look like which is being assigned to the "InfoTable"

Hi Sushant,

Datashape is also having only two properties.

sharing screenshot of datashape.

Also cross checked infotable level also.its having only two columns.

Regards,

Raji

supandey
19-Tanzanite
(To:rvuta1)

Raji I think the issue here is that you are passing the values for the property to the GetNamedPropertyValues where as it's expecting Infotable which contains the DS that holds the PropertyName. You can check this by testing the GetNamedPropertyValues service and you'll see as an input it requires you to enter the propertyName and description. In which PropertyName is a mandatory field.

So you'll need to pass such an Infotable and the values that you want to insert and I think the PropertyNames should match to the PropertyName you have in Thing

supandey
19-Tanzanite
(To:supandey)

Here's a quick demo

1. Created a Infotable with DS that has filed name and description, of course you don't have to create a property with Infotable like this you can simply create that in your script

2. Here's how my service looks like :

var params = {

  propertyNames: me.PropertyForGetPropertyValues /* INFOTABLE */

};

// result: INFOTABLE dataShape: "undefined"

var result = me.GetNamedPropertyValues(params);

3. Do note that my returned output contains the DS which matches with the required Output for my data, like so

Hope this will help.

Sushant,

As per my understanding Infotable result should be the property names of my thing.

this propertynames values will pass to SQL service and gives result/values  of sql properties.

So I didn't understand why sql service will check for DataShape property names instead of values , which are same as Propertynames of my Thing.

pls correct me if I am wrong.

Regards,

Raji.

supandey
19-Tanzanite
(To:rvuta1)

Raji,

What I have explained above is the usage of GetNamedPropertyValues which will produce following result and as to why you are getting that error.

Your understanding is right that the returned Infotable will give you the PropertyValues however the reason why you should be particular about the DS is because the Infotable produced as the Output must give you the values with correct dataType. And same applies for the Infotable you are inputting because the GetNamedPropertyValues expects you to give input in certain type of DataShape which is Name and Description both of string baseType. Of course once you have the values you are free to use them in any other service such as the SQL script.

Hi Sushant,

Thanks for your reply.

have tried in same way what ever you have mentioned.but not getting the result.

sharing screen shots of same.

1.Infotable created.

2..Service :

Result :

Regards,

raji

supandey
19-Tanzanite
(To:rvuta1)

Is it correct that your DS Fields have number as baseType? From the result you shared above it appears as though you are using same DS for input and output Infotables and also the values you are returning is of String baseType. If you scroll to the right (unfortunately my screenshot is too big so you'll have to scroll to see the Infotable assigned to the input infotable) you'll see that the input DS has string baseType fields which denotes

Hi sushant,

Thank you so much for your help.

now its working correctly by adding a datashape with properties as name and description.

Regards,

raji.

supandey
19-Tanzanite
(To:rvuta1)

Glad it worked out.

Top Tags