cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
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
Highlighted
Solution Supplier
Solution Supplier

Re: Set variable a value from fetch that returns one record

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

Highlighted
Helper II
Helper II

Re: Set variable a value from fetch that returns one record

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
Highlighted
Solution Supplier
Solution Supplier

Re: Set variable a value from fetch that returns one record

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

Highlighted
Helper II
Helper II

Re: Set variable a value from fetch that returns one record

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

Highlighted
Helper II
Helper II

Re: Set variable a value from fetch that returns one record

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
Community Conference

Power Platform Community Conference

Check out the on demand sessions that are available now!

Watch Now

Experience what’s next for Power Apps

See the latest Power Apps innovations, updates, and demos from the Microsoft Business Applications Launch Event.

Power Platform ISV Studio

Power Platform ISV Studio

ISV Studio is designed to become the go-to Power Platform destination for ISV’s to monitor & manage published applications.

secondImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

Users online (6,761)