web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Pages / Comma Separate the Fet...
Power Pages
Answered

Comma Separate the Fetch XML Output and assign the output to a liquid variable

(0) ShareShare
ReportReport
Posted on by Microsoft Employee

Hello Experts,

 

I have a fetch XML query that gives the list of available organization in the CDS entity. I need to list all the organizations using the fetch XML and separate the fetch XML  output using a comma and then assign it to a liquid variable.

My fetch XML query is as below,

{% fetchxml my_query %}
<fetch version="1.0" output-format="xml-platform" mapping="logical" distinct="false">
<entity name="organization_entity">
<attribute name="organization_entity" />
<order attribute="organization_entity" descending="false" />
<filter type="and">
<condition attribute="organization_entity" operator="not-null" />
</filter>
</entity>
</fetch>
{% endfetchxml %}

{% for result in my_query.results.entities %}
{% assign org = result.organization_entity | join:  "," %}
{% endfor %}
In this case I get the output as:
T, e, s, t, , C, o, m, p, a, n, y, , 1T, e, s, t, , C, o, m, p, a, n, y, , 2
 
I want to get the output as Test Company 1, Test Company 2. and then assign it to a liquid variable. Could anyone please help me on achieving this..
Your help is greatly appreciated.
Thank you
 
Categories:
  • oliver.rodrigues Profile Picture
    9,482 Most Valuable Professional on at

    Hi, I think you are missing your "name" attribute there. But don't think that's the issue. 

    I don't think you need the | join filter there. 

    In your loop try something like this:

    {% for result in my_query.results.entities %}
     result.organization_entity{% unless forloop.last %},{% endunless %}
    {% endfor %}
  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    Hi @OliverRodrigues ,

    Thank you for your reply.. Could you please let me know how the comma separated value can be assigned to a variable as I need to use that variable again in my code..

    Your help is greatly appreciated.

    Thank you!

  • Verified answer
    oliver.rodrigues Profile Picture
    9,482 Most Valuable Professional on at

    Hi you should be able to use the capture Liquid tag:

     {% capture my_variable %}
     {% for result in my_query.results.entities %}
     {{ result.organization_entity }}{% unless forloop.last %},{% endunless %}
     {% endfor %}
     {% endcapture %}
     my_variable --> {{ my_variable }}

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Leaderboard > Power Pages

#1
M Bilal Khan Profile Picture

M Bilal Khan 139

#2
Mohsin Ali Profile Picture

Mohsin Ali 41

#3
11manish Profile Picture

11manish 19 Super User 2026 Season 2

Last 30 days Overall leaderboard