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

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

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
 
1 ACCEPTED SOLUTION

Accepted Solutions
OliverRodrigues
Super User
Super User

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



If you like this post, give a Thumbs up. Where it solved your request, Mark it as a Solution to enable other users find it.

Power Apps Portals Super User


Oliver Rodrigues


 

View solution in original post

3 REPLIES 3
OliverRodrigues
Super User
Super User

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 %}



If you like this post, give a Thumbs up. Where it solved your request, Mark it as a Solution to enable other users find it.

Power Apps Portals Super User


Oliver Rodrigues


 

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!

OliverRodrigues
Super User
Super User

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



If you like this post, give a Thumbs up. Where it solved your request, Mark it as a Solution to enable other users find it.

Power Apps Portals Super User


Oliver Rodrigues


 

View solution in original post

Helpful resources

Announcements
PA_User Group Leader_768x460.jpg

Manage your user group events

Check out the News & Announcements to learn more.

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

Welcome Super Users.jpg

Super User Season 2

Congratulations, the new Super User Season 2 for 2021 has started!

Carousel 2021 Release Wave 2 Plan 768x460.jpg

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

Users online (1,016)