Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics 365 | Integration, Dataverse...
Answered

how to fetch current record in liquid template language in a web form

(1) ShareShare
ReportReport
Posted on by 19

I am using a a web form in Dynamics 365 Portal. The web form has multiple steps. The WebForm is flagged not to always create a session, rather use existing session. When a user does not finish to complete the web form, it is usually stored in a Draft status in the entity to which the webform is bind with, so what I need to do is to fetch the unfinished draft record from the entity. How can I do this in liquid template language? I know that liquid template language provides implicit objects like entities['entitiyname']['recordid'] , but the problem I am facing I am not able to get the recordid in liquid template language so that i can pass it as paarameter in implicity object entities , i.e. entities['entityname']['recordid']. I want to do this in the third step of the Web Form. Does anyone know how I can get the current record Id in liquid template language? 

Please dont just share the generic links of the tutotrials, as i have gone through the Microsoft Documenttion and still I have not been able to achieve it. I have also followed many available articles or threads, but didn't get through the problem

  • Verified answer
    octopus Profile Picture
    octopus 19 on at
    RE: how to fetch current record in linquid template language in a web form

    Thanks Nya, I found the solution which I will discuss here. First of all, I just need to hihghlight that in implicit object enitities, one must provide a  primary key of to fetch the record, i.e. recordid in entities['entityname']['recordid'] must be a primary key value.

    Anways, to get the draft record saved in the entity of a WebForm or AdvanceForm (both are same), we need the primary key of that draft record first. And that can be retrieved from adx_primaryrecordid column of the adx_webformsession table. 

    since there are multiple session records in adx_webformsession table itself, so we need to get the session record which is associated with draft record of the entity of a WebForm. We know a WebForm stores its configuration record in adx_webform table, we can access configuration record id using page.adx_webform.id. Don't assume here, that now can run liquid template entities['adx_webformsession'][page.adx_webformsession.id] to get session record because page.adx_webformsesion.id on page level in liquid template doesn't refer to primary key of adx_webformsession table and I did this mistake in my case, therefore we need to run fetchxml as follows and directly just get the required attribute from the session record i.e. adx_primaryrecordid discussed above  :

    {% fetchxml webformsessions %}
    <fetch top="1">
    <entity name="adx_webformsession" >
    <attribute name="adx_primaryrecordid" />
    <attribute name="adx_primaryrecordentitylogicalname" />
    <filter type="and" >
    <condition attribute="adx_webform" operator="eq" value="{{ page.adx_webform.id }}" />
    <condition attribute="adx_contact" operator="eq" value="{{ user.id }}" />
    </filter>
    <order attribute="createdon" descending="true" />
    </entity>
    </fetch>
    {% endfetchxml %}

    {% for item in webformsessions.results.entities %}
    {% assign recordid = item.adx_primaryrecordid %}
    {% endfor %}

    Now, that we have recordid , we can get the draft record of the WebForm using entities['entitityname']['recordid']

    Note that, if above fetchxml doesnt return result it means you might not have permissions in Table Permissions confiuration of the Dynamics Portal. I faced this issue and I coudln't get my head around for hours to find the actual cause. So I added the Table Permissions record as follows:

    Name: WebFormSession-Permission-Contact (Can be anything)
    Access Type: Contact
    Table Name: adx_webformsession
    Web Roles: Authenticated User, Administrator (these are the roles in my case, use your own roles who you want to give the permissions to)
    Permissions: ReadOnly

  • Nya Profile Picture
    Nya 29,058 on at
    RE: how to fetch current record in linquid template language in a web form

    Hi,

    Would you please share some code snippets about the issue?

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

Congratulations 2024 Spotlight Honorees

Kudos to all of our 2024 community stars! 🎉

Meet the Top 10 leaders for December

Congratulations to our December super stars! 🥳

Start Your Super User Journey

Join the ranks of our community heros! 🦹

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,784 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,476 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Product updates

Dynamics 365 release plans