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

Community Tip - Help us improve the PTC Community by taking this short Community Survey! X

Get thing by name

drichter
14-Alexandrite

Get thing by name

Hi,

My idear:

I have a mashup which is slit into two sections.

Section #1 is a list with names of existing things (only strings). If I click on a name a mashup with this selected thing is show in section #2.

My problem:

Section #2 is a submashup. I give the selected name as input into the submashup. I wrote a service which should give me the thing by name. I try this with:


result = Things[Name];


and with

var params = {

    identifier: Name

};

result = Resources["EntityServices"].GetThingNameForIdentifier(params);

The first variant throw a "Invalid Reference to ThingWorx Entity" error message in the script log.

The second variant does not throw an error but its return undefinded.

4 REPLIES 4
jamesm1
5-Regular Member
(To:drichter)

Try result = Things[Name].name

Thanks!

-James

Edit: Actually, I might be misunderstanding -- what are you trying to return? You can't just return the Thing, that would be an Object. Are you trying to return the Thing properties?

drichter
14-Alexandrite
(To:jamesm1)

I try to show what I mean with an image:

Zwischenablage03.png

On the right side is a list of things. If I click of one of them the lower section have to change. The lower section is a submashup which have an input type of THINGNAME (which mean a thing). With the getThingByName I want that its return the thing of the selected thing name and put it in the input params of the second section.

jamesm1
5-Regular Member
(To:drichter)

It looks like you want to dynamically pull the properties of the selected thing based on the selection?

If so, add the Thing as you would normally add data, but check the Dynamic button:

Then bind your Thing name to the EntityName parameter on the service:

Finally, trigger to run the service on the entity change event from your rmashup parameter.

Hope this helps!

drichter
14-Alexandrite
(To:jamesm1)

So, now I'm a little step fourther. I used

var params = {

    identifier: Name

};

result = Resources["EntityServices"].GetThingNameForIdentifier(params);

and Add a Identifier to the thing. Next I add a refresh to of getProperties-Service if the inputthing changed. The only problem that I still have, I will get the thing by name not by an extra identifier.

Announcements


Top Tags