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

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Pages / How to Make Field Opti...
Power Pages
Answered

How to Make Field Optional in Portal Web Form Step

(0) ShareShare
ReportReport
Posted on by 6

I have Portal Web form with multiple steps. On one of the step i am using Form created in Entity(CDS). Entity field is Business Recommended which then can be marked as Required on the web form. Field is used in Multiple Web Forms and on one of the web Form i want to make it optional. I can remove Business recommendation for the field and write Javacript to make it Mandatory but because the field is used in many forms and just one form need that to be made Optional so thinking of implementing something that wont break existing setup. Can someone please suggest how this can be achieved. Thanks in advance

Categories:
I have the same question (0)
  • H V Profile Picture
    1,510 on at

    Hi @PRV2TECH

    You can set field as Optional from entity meta data.

     

    Please refer below link:

    https://www.google.com/amp/s/www.inogic.com/blog/2018/12/how-to-make-optional-fields-as-mandatory-fields-in-dynamics-365-portal/amp/

     

    --------------------------
    If you like this post, give a Thumbs up. Where it solved your query, Mark as a Solution so it can help other people!

  • Fubar Profile Picture
    8,487 Super User 2026 Season 1 on at

    Note: you cannot make a mandatory field optional via metadata as suggested by someonelse

     

    In your case, on the form that it needs to be optional, on the Entity Form uncheck the option that makes Business Recommended Mandatory, if you have other Business Recommended fields on that form create Metadata items for that Entity Form to set each of those attributes mandatory.

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

    Hi

     

    I actually don't think you can bypass that via JS or anything else in the Portals. It will enforce your entity model restrictions.

    The only way here is doing the opposite, keeping Optional in the CDS level, and making mandatory via Web Form Metadata for your other pages.


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

    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.

  • PRV2TECH Profile Picture
    6 on at

    Thank you everyone, i have to implement this using Javascript which worked fine. 

     

    ValidatorEnable($('[id*=RequiredFieldValidator"+fielName+"]')[0], false);
    $('#"+fielName+"_label').parent().removeClass('required');

     

    Below post helped the implementation. Tried to get around using webtemplate but couldn't get working using Liquid in Webform.

    https://www.futurezconsulting.com/2018/06/04/portals-validators/

     

  • justinburch Profile Picture
    Microsoft Employee on at

    Hi @PRV2TECH,

    Have you tested that it works? I've had issues with removing the validators client-side where the form would still not submit due to server-side failure. Typically, removing validators with JS works when it was originally added with JS. I can't recall if my issues were with Required via field vs. Entity Form Metadata, or both.

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    Yes, you can remove a required field using JS.

    I've done this before on a jQuery document ready. Something like this will do it.

     

    //eg. removeValidator("customerid")
    function removeValidator(fieldName) {
     var count = 0;
     for(var i =0; i < Page_Validators.length - count; i++){
     if (Page_Validators[i - count].id == "RequiredFieldValidator" + fieldName) {
     Page_Validators.splice(i - count, 1);
     count++;
     }
     }
     $("#" + fieldName + "_label").parent().removeClass("required");
    }

     

     

     

  • PRV2TECH Profile Picture
    6 on at

    I have used below function in live portal website and working as expected. Change field name and use below script inside Custom Javascript of Web Form -> Web Step. 

     

    if (window.jQuery) { (function ($) { $(document).ready(function () { if (typeof (Page_Validators) === 'undefined') return; var fieldName="customer_name"; ValidatorEnable($('[id*=RequiredFieldValidator"+fieldName+"]')[0], false); $('#"+fieldName+"_label').parent().removeClass('required'); }); }(window.jQuery)); }

  • Verified answer
    Community Power Platform Member Profile Picture
    Microsoft Employee on at

    Great news. Could you mark this as 'Solved' if all is now working as you expected.

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Congratulations to the March Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Pages

#1
rezarizvii Profile Picture

rezarizvii 61

#2
11manish Profile Picture

11manish 40

#3
oliver.rodrigues Profile Picture

oliver.rodrigues 36 Most Valuable Professional

Last 30 days Overall leaderboard