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

Community Tip - Learn all about PTC Community Badges. Engage with PTC and see how many you can earn! X

Passing values between Mashups and Contained Mashups

mfgpartner
12-Amethyst

Passing values between Mashups and Contained Mashups

Hi. I'm taking on my first attempt to building a "object based" display/mashup that's basically a mashup with 5+ contained mashups, widgets, a menu, and security. I'm hoping to start off with some best practices that everyone can share. My goal is to be able to make modifications to the contained mashups so that I wouldn't have to make changes "everywhere". Here's what I'm trying to achieve and have gathered from reading on discussions here and some trial and error.

1. Passing values into a contained mashup - It seems like there are 3 ways to passing values into a contained mashup.

    1. Pass an entity into the Entity property of the contained mashup widget. I've managed to do this by grabbing the name field out of the GetImplementingThings service and passing it to the contained mashup's Entity property.
    2. Add custom session variables and set them by the main mashup and have the contained mashup pull it. (?)
    3. Add mashup parameters that are named the same to pass values. (?)

I believe 1.a works great if you have Things all setup in ThingWorx, and thus entities. But if, instead of a list box that lists Things based on ThingTemplates, I have a list box based on records from a database and I want to pass the primary key (Id) around? I imagine I'll have to use 1.b or 1.c, correct?

2. Passing values from a contained mashup to the parent mashup - Looks like the same 3 ways as above? The entity property of the contained mashup widget has two way arrows, so it seems like I can send an entity back up. But if I'm passing a value into the contained mashup to load a database table and I want to pass the ID selected in the grid back up to the parent, I imagine I'd need to use session variables or mashup parameters too.

On a side note, I've seen/used ​​name​ out of GetImplementingThings and it seems to be the same as ​Entity​ and EntityName​. Is this an actual object that's being passed around or just text? If it's just text, would I be able to bind a database field's text (that's named the same as a Thing) over the Entity or EntityName properties/parameters?

Thanks a ton ahead of time.

Michael

4 REPLIES 4
PaiChung
22-Sapphire I
(To:mfgpartner)

1. Just make sure you have a column with the IDs in the infotable that is coming to the mashup. you can use the Selected Row and bind the ID instead of the displayed values.

2. Indeed you can pass information back and forth, you will need two different mashup parameters to do what you want to do.

Thanks for the response Pai. I actually saw the post you made about mashup parameters and that's the only reason I'm aware of them. Are there inefficiencies to using session variables vs mashup variables? Just wondering if there's a best practice.

Thanks,

Michael

PaiChung
22-Sapphire I
(To:mfgpartner)

Session parameters are very power and can be set from anywhere, so you lose the direct link and it may be harder to track what the actual value is.

Mashup parameters are 'local' in scope and so it is a nice direct relationship without any ambiguities.

Understood. Thanks Pai!

Announcements


Top Tags