cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
TheIntern
Helper II
Helper II

Liquid fetchxml get optionset/lookup value from linked entity

I am joining two entities with a fetchxml query.

<fetch top="50" >
<entity name="entity1" >
<attribute name="field1" />
<filter>
</filter>
<link-entity name="entity2" from=".." to=".." alias="aa">
<attribute name="field2" />
<attribute name="field3" />
</link-entity>
</entity>
</fetch>

 

field 2 and field 3 are lookup and optionset respectively. I am trying to access the values using result['entity2.field2.name'] and result['aa.field3.label'], but i get blank for both.

 

Is there a way to get these values?

1 ACCEPTED SOLUTION

Accepted Solutions
Fubar
Solution Sage
Solution Sage

Is there a way to get the value, Yes.  I can't remember exactly off the top of my head using the array notation but I think you have too much in the [].

Something more like result['aa.field3'].label

 

also see

https://powerusers.microsoft.com/t5/Building-Power-Apps/Portal-Liquid-Template-with-FetchXML-OptionS...

View solution in original post

3 REPLIES 3
justinburch
Microsoft
Microsoft

Assuming result is the iterative object from your for loop, try {{ result.aa.field3.label }} - otherwise it's expecting aa.field3.label to be a static string. Also, try filtering your fetch to only those that have data in field3 to ensure you're testing against data that should have a value.

 

Fubar
Solution Sage
Solution Sage

Is there a way to get the value, Yes.  I can't remember exactly off the top of my head using the array notation but I think you have too much in the [].

Something more like result['aa.field3'].label

 

also see

https://powerusers.microsoft.com/t5/Building-Power-Apps/Portal-Liquid-Template-with-FetchXML-OptionS...

C2GUY
Helper I
Helper I

I would ensure you can retrieve the ID first.

{{ result['aa.field2'].id }}

Once you have got the ID coming back, that proves your permissions are Okay.

Then I suggest trying to get the text value back, but depending on the field type you have setup try the following:

{{ result['aa.field2'] }}      
{{ result['aa.field2'].value }}
{{ result['aa.field2'].label }}
{{ result['aa.field2'].text }}
{{ result['aa.field2'].name }}

{{ result['aa.field3'] }}        
{{ result['aa.field3'].value }}
{{ result['aa.field3'].label }}
{{ result['aa.field3'].text }}
{{ result['aa.field3'].name }}

Let me know if this helps.

 

Helpful resources

Announcements
October Events

Mark Your Calendars

So many events that are happening this month - don't miss out!

MPP IDEAS

Ideas

Discover ideas and concepts from users like you for how to use Power Pages and take your work to the next level.

Ignite 2022

WHAT’S NEXT AT MICROSOFT IGNITE 2022

Explore the latest innovations, learn from product experts and partners, level up your skillset, and create connections from around the world.

Carousel Community Blog

Check out the Community Blog

Read all about the most recent blogs in the community!

Users online (2,335)