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

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group

MBAS Attendee Badge

Claim Your Badge & Digital Swag!

Check out how to claim yours today!

secondImage

Demo Extravaganza is Back!

We are excited to announce that Demo Extravaganza for 2021 has started!

MBAS on Demand

Microsoft Business Applications Summit sessions

On-demand access to all the great content presented by the product teams and community members! #MSBizAppsSummit #CommunityRocks

Users online (72,559)