web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Pages / Liquid - Passing param...
Power Pages
Unanswered

Liquid - Passing parameter to webtemplate

(0) ShareShare
ReportReport
Posted on by 6

Hi All,

 

I'm struggling with a simple requirement and hopefully someone went through it before and can help me out.

 

I have a web template called "Return Contact" that serves me as a server function, in it I simple have a fetchxml that returns me a contact based on a parameter dn. Everything works fine when I pass the parameter as a simple string like this:

 

<script>

var result = {% include 'Return Contact' dn:'123' %}
</script>
 
But my problem is, the parameter is within a variable, so I need to do something like this:
 

<script>

var myVar = '123';

var result = {% include 'Return Contact' dn:myVar %}
</script>
 
But for some reason it doesn't work, I simply need to pass a parameter that is held within a JS variable to my web template. Thoughts? Thanks
Categories:
I have the same question (0)
  • msftheavyuser2 Profile Picture
    6 on at

    I realize now that liquid code renders before JS code, so my JS variable doesn't get rendered in time. Is there anyway for me to send information that is in the client to the server? I need to send a value that is processed in my JS code to my web template

  • AndKanPA Profile Picture
    214 on at
  • msftheavyuser2 Profile Picture
    6 on at

    Thanks, but it didn't help. My problem is that I need to run a javascript code before the liquid code, can I do this?

  • oliver.rodrigues Profile Picture
    9,368 Most Valuable Professional on at

    Hi, can you explain where the DN variable is coming from? 

    are you for example looping through an entity list and getting the contact details? 

    also when are you triggering that code? is it on page load?

    is contact you want to load the current logged in contact? or a different contact?

     

    this might help us giving you alternatives of what you are trying to achieve

     

    ------------

    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.

  • msftheavyuser2 Profile Picture
    6 on at

    Hi @OliverRodrigues ,

     

    This is my scenario:

    A unauthenticated user goes to my portal page with an encrypted url ie:

    https://myorg.powerappsportals.com/mypage/?U2FsdGVkX1/e312Vuj9s

    Then I get the URL parameters and I decrypt it using a JS library and I store the content in a variable (myVar).

    The decrypted contains the ID of my unauthenticated user (Custom Contact Entity) that I then try to pass to my web template

     

    <script>

    var myVar = JsLibrary.Decrypt(URL, "secret");

    var result = {% include 'Return Contact' dn:myVar %}
    </script>
     
    The code is in the HTML field of the localized content page
  • oliver.rodrigues Profile Picture
    9,368 Most Valuable Professional on at

    okay, in this case I actually don't think you need JS code.. you can achieve that all via Liquid

    if this is happening on the onload of the page, you can create your own Web Template, read the query string parameter and include call your "Return Contact" template

    you can read the parameter via liquid using something like the following:

    {% assign id = request.params['id'] %}
    

     just wondering as well.. are you trying to achieve something like an authentication process? what do you do after decrypting and return the contact details? are the users logging in to your portal? 

  • OOlashyn Profile Picture
    3,496 Most Valuable Professional on at

    Hi @msftheavyuser2 ,

     

    The previous reply from @OliverRodrigues should help you. However, if you need to obtain data dynamically from javascript you can check these articles from Colin Vermander (first and second). In short, you use your web page as some sort of web API to retrieve data.

Under review

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

Helpful resources

Quick Links

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Pages

#1
Jerry-IN Profile Picture

Jerry-IN 71

#2
Fubar Profile Picture

Fubar 62 Super User 2025 Season 2

#3
sannavajjala87 Profile Picture

sannavajjala87 31

Last 30 days Overall leaderboard