Skip to main content

Notifications

Announcements

No record found.

Customer Insights - Journeys forum
Under review by Community Managers

Under review

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

fetchXML and loop through the data set with JavaScript

Posted on by 459

Hi 

I used fetchXml to retrieve data from the entity and loop through the data set using JavaScript. However, when I loop through the data, I am getting an empty result (refer to the JAVASCRIPT code below).

Could you advise how i can get each data from the collection?

alert('{{porvinces[i].value}}');  //this line return empty

alert('{{porvinces[0].value}}');  // this line return the right value 

{% fetchxml provinces%}
<fetch top="50" >
<entity name="stringmap" >
<attribute name="attributevalue" />
<attribute name="displayorder" />
<attribute name="objecttypecodename" />
<attribute name="attributename" />
<attribute name="value" />
<attribute name="objecttypecode" />
<attribute name="langid" />
<attribute name="stringmapid" />
<filter type="and" >
<condition attribute="attributename" operator="eq" value="provincesterritories" />
</filter>
</entity>
</fetch>
{% endfetchxml %}
{% assign porvinces = reasonEntries.results.entities %}
JAVASCRIPT code

<script type="text/javascript">
$("document").ready(function() {
var entitySize="{{provinces.results.entities.size}}";
var i=0;
var entityObj;

for(i=0;i < entitySize;i++ )

alert('{{porvinces[0].value}}');  // i get the right value 
alert('{{porvinces[i].value}}');  //this line return empty

}
});
</script>

Helpful resources

Quick Links

November Spotlight Star - Khushbu Rajvi

Congratulations to a top community star!

Forum Structure Changes Coming on 11/8!

In our never-ending quest to help the Dynamics 365 Community members get answers faster …

Dynamics 365 Community Platform update – Oct 28

Welcome to the next edition of the Community Platform Update. This is a status …

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,253 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,188 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans