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

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...

View solution in original post

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
PA User Group

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group

MBAS Attendee Badge

Claim Your Badge & Digital Swag!

Check out how to claim yours today!

secondImage

Demo Extravaganza is Back!

We are excited to announce that Demo Extravaganza for 2021 has started!

MBAS on Demand

Microsoft Business Applications Summit sessions

On-demand access to all the great content presented by the product teams and community members! #MSBizAppsSummit #CommunityRocks

Users online (30,950)