Skip to main content

Notifications

Community site session details

Community site session details

Session Id :
Power Pages - Customize & Extend
Suggested answer

Adding Liquid Code for Field Validation in a step of a Multistep Form

(1) ShareShare
ReportReport
Posted on by 12
Hi Community,

I have a multistep form, where in the first step I need to perform a validation to check for duplication of data in the database on one specific field on the first step of this form.
The Liquid Code to accomplish this is this one, but I am not sure how to add this code to the step in the form:

{% if entity.cr5d9_nro_id_fiscal %}
    {% fetchxml proveedor_query %}
        <fetch top="1">
            <entity name="cr5d9_datos_proveedor">
                <attribute name="cr5d9_nro_id_fiscal" />
                <filter>
                    <condition attribute="cr5d9_nro_id_fiscal" operator="eq" value="{{ entity.cr5d9_nro_id_fiscal }}" />
                </filter>
            </entity>
        </fetch>
    {% endfetchxml %}
    
    {% if proveedor_query.results.entities.size > 0 %}
        {% validation "cr5d9_nro_id_fiscal" "This Fiscal ID is already registered in the database." %}
    {% endif %}
{% endif %}
 
How do I add this code to the multistep form ?  I am not sure I am missing steps for configuration in the Power Pages Admin Portal or overlooking something

I can see the code calling the Multistep form  like this :

<div data-component-theme="portalThemeColor7" class="row sectionBlockLayout text-start" style="display: flex; flex-wrap: wrap; margin: 0px; min-height: auto; padding: 8px; border: 0px solid rgb(0, 0, 0); border-radius: 0px; background-position: center center; background-repeat: no-repeat; background-size: cover;">
  <div class="container" style="display: flex; flex-wrap: wrap; column-gap: 0px;">
    <div class="col-lg-8 columnBlockLayout" style="flex-grow: 1; display: flex; flex-direction: column; min-width: 250px; padding: 16px; margin: 60px 0px; width: calc(66.6667% + 0px);">{% webform name: 'RegistraProveedorPorPasos' %}</div>
    <div class="col-lg-4 columnBlockLayout" style="flex-grow: 1; display: flex; flex-direction: column; min-width: 250px; padding: 16px; margin: 60px 0px; width: calc(33.3333% + 0px);">
      <p><br /></p>
    </div>
  </div>
</div>
 
I will really appreciate any suggestion you may have,
 
Best Regards,
 
Carlos.
Categories:
  • Suggested answer
    oliver.rodrigues Profile Picture
    9,315 Most Valuable Professional on at
    Adding Liquid Code for Field Validation in a step of a Multistep Form
    A few things here:
     
    • Dataverse plug-ins might be the way to go, since it happens server-side and you have a lot of flexibility there
    • You can also look at Dataverse Alternate Keys, perhaps against the lookup to the parent record within your child table, this would ensure that the record is unique - issue here might be that you can't customize the exception message
    • You can use the result of Liquid within a Form Step
      • basically you add the Liquid into the Form Step JavaScript
      • the Liquid will evaluate first (server-side) and the JS will read the outcome of the Liquid
      • ultimately, your JS will be responsible for the logic
  • Suggested answer
    Fubar Profile Picture
    7,930 Super User 2025 Season 1 on at
    Adding Liquid Code for Field Validation in a step of a Multistep Form
    There can be different approaches to this depending on how secure etc things need to be.
     
    If all you need is to check the value, one approach is to make the query client-side via a Power Pages Flow and return a true/false or string back from the Flow. 
    What you may consider in this type of case is disabling the Next button, adding your own 'Check' button  (append it to the DOM using JavaScript/JQuery) next to the field that will make the Power Pages Flow call when clicked, then enabling the Next button if the check is successful. You could also try adding to the steps Validator (add the validator to the JavaScript area in the Step from the Power Pages Management App) but, usually this tricks people up due to how the Promises works) https://learn.microsoft.com/en-us/power-pages/configure/add-custom-javascript#additional-client-side-field-validation
     
    Alternatively validate via real-time plugin or dataverse workflow on create/update of the respective record.
     
    As per previous comment, Liquid runs after a page is called to be loaded (not on submit of the current page), and its output along with other HTML etc is then sent to the Browser for it to be rendered, so generally would not be suitable for doing actual validation. But in certain scenarios may be used to populate a JavaScript object that can then be checked by the the JavaScript on a Step etc (but the suitability of this depends on your exact scenario due to timing between when a page loads and the subsequent submit & validation occurs)
     
     
     
  • CBDEV Profile Picture
    12 on at
    Adding Liquid Code for Field Validation in a step of a Multistep Form
    Hi  @Ajlan, thank you for pointing me in the right direction. Most of the explanations I was reviewing were missing these important steps you are mentioning. I will do some tests and let you know. Even the IA checks were omitting all this information. The Dataverse Plugin seems the way to go.
     
    Best Regards,
     
    Carlos.
  • Suggested answer
    Ajlan Profile Picture
    183 on at
    Adding Liquid Code for Field Validation in a step of a Multistep Form
    Hello Carlos,
     

    You cannot add Liquid templates directly on multistep form steps in Power Pages.

    First, you need to create a Web Template and a Page Template, then link the Web Template to the Page Template. Finally, assign the created Page Template to the Page where you're displaying your multistep form. Liquid is only processed during page rendering, not during form step execution.

    For server-side validation like duplicate checks, I recommend creating a Dataverse plugin, it ensures reliable validation regardless of how the data is submitted.

    Cheers! 🎉

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

Michael Gernaey – Community Spotlight

We are honored to recognize Michael Gernaey as our June 2025 Community…

Congratulations to the May Top 10 Community Leaders!

These are the community rock stars!

Announcing the Engage with the Community forum!

This forum is your space to connect, share, and grow!

Leaderboard >

Featured topics