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

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

Portals: Is it possible to pass a Liquid variable to a JS function?

(0) ShareShare
ReportReport
Posted on by 414

Hello everyone,

I am working on a custom template on Portal and I was wondering if it is possible to pass to a JS function as parameter a Liquid variable.

Was not able to find a way to do this so far, maybe anyone has more knwoledge on Liquid - JS interaction ...

....

.....

 {% assign test = 0 %}

...

..

<script type="text/javascript" charset="UTF-8" >

function showMsg(test ) {

.....

....

}

</script>

Many thanks in advance,

Irena.

*This post is locked for comments

I have the same question (0)
  • Verified answer
    Mahendar Pal Profile Picture
    45,095 on at

    Hello,

    Assuming you want to use liquid variable in your js method in liquid template, so once you have defined your liquid variable you can use it in your js method

    {% assign test = 0 %}

    //calling liquid variable in js

    var testval= '{{test }}';

  • Aric Levin - MVP Profile Picture
    30,190 Moderator on at

    Yes you can as long as you use the liquid tags:

    showMessage({{test}});

    Hope this helps.

  • Community Member Profile Picture
    on at

    Can we do the opposite? I mean assigning the result of a JS function to be assigned to a Liquid variable?

  • AkshayShah Profile Picture
    70 on at

    Hello Mahendra,

    I have some vice-versa requirement that,

    There is one Date field. on date field change i have to apply filter in fetch xml.

    so how to get user selected date in liquid script??

    Thanks in advance..

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
SA-08121319-0 Profile Picture

SA-08121319-0 4

#1
Calum MacFarlane Profile Picture

Calum MacFarlane 4

#3
Alex Fun Wei Jie Profile Picture

Alex Fun Wei Jie 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans