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

Set variable a value from fetch that returns one record

I have a fetchxml that returns one record. I put it in liquid.

The value of one field from this record has to be used further as URL for HTTP request. (ajax in javascript)

How can I do this?

2 ACCEPTED SOLUTIONS

Accepted Solutions
justinburch
Microsoft
Microsoft

Hi @eliz_talent,

I typically use hidden inputs to host singular variables like that. E.g.:

{% assign acct = entities.account[params.id] %}
{% if acct %}
  {% assign acctHiddenStuff = acct.new_hiddenstuff %}
{% endif %}
<input type="hidden" id="hiddenStuff" value="{{ acctHiddenStuff }}">

used with 

var hiddenStuff = $("#hiddenStuff").val();
if (hiddenStuff !== "") {
  // do something
}

 

View solution in original post

I have found a solution. I didn't give me the permission to read this entity and the fetch was empty.

View solution in original post

3 REPLIES 3
justinburch
Microsoft
Microsoft

Hi @eliz_talent,

I typically use hidden inputs to host singular variables like that. E.g.:

{% assign acct = entities.account[params.id] %}
{% if acct %}
  {% assign acctHiddenStuff = acct.new_hiddenstuff %}
{% endif %}
<input type="hidden" id="hiddenStuff" value="{{ acctHiddenStuff }}">

used with 

var hiddenStuff = $("#hiddenStuff").val();
if (hiddenStuff !== "") {
  // do something
}

 

View solution in original post

Hi @justinburch,

thank you for your time and the response.

how can I assign a value if I do not have the id of the setting record (I fetch top 1 record)? 

 

Current code does not work for me, URL remains empty:

{% for item in settingsFetch.results.entities %}
{% assign url = {{item.url}} %}
{% endfor %}

I have found a solution. I didn't give me the permission to read this entity and the fetch was empty.

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.

Power Query PA Forum 768x460.png

Check it out!

Did you know that you can visit the Power Query Forum in Power BI and now Power Apps

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.

R2 (Green) 768 x 460px.png

Microsoft Dynamics 365 & Power Platform User Professionals

DynamicsCon is a FREE, 4 half-day virtual learning experience for 11,000+ Microsoft Business Application users and professionals.

Users online (2,534)