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 / Javascript to display ...
Power Pages
Answered

Javascript to display default label on choice field

(0) ShareShare
ReportReport
Posted on by 90

I am using a model driven app form on the Portal. Is there a way to display a default "--Select--" label on a dropdown field when the form first loads, without creating an actual choice called "--Select--" and assigning that as default. Looking to avoid the problem if user does not select anything, then the default value assigned should be blank and not --Select--

 

@OliverRodrigues 

Categories:
I have the same question (0)
  • yashag2255 Profile Picture
    24,769 Super User 2024 Season 1 on at

    Hi @Mikello-6626 

     

    To configure this you can use Entity Form Metadata on the form of type attribute and then provide the default value that you are looking for.

     

    Hope this Helps!

     

    If this reply has answered your question or solved your issue, please mark this question as answered. Answered questions helps users in the future who may have the same issue or question quickly find a resolution via search. If you liked my response, please consider giving it a thumbs up. THANKS!

  • Mikello-6626 Profile Picture
    90 on at

    @yashag2255 No, it does not work for choice field. Have you tried it?

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

    Hi, you can apply JS to achieve that, something like:

    $("#<choice field name>").find("option[value='']").attr("label", "--SELECT--")

     

  • Mikello-6626 Profile Picture
    90 on at

    Thank you so much for your prompt response as always. I am very close to this but for some reason my Power flow is failing because it detects as no value. Any way to assign a value like "Not selected" behind the scenes if a user keeps it as default "--Select--"? I tried assigning value in this code but it's not working 

    $("#<choice field name>").find("option[value='None selected']").attr("label", "--SELECT--")
  • Verified answer
    oliver.rodrigues Profile Picture
    9,368 Most Valuable Professional on at

    So, your flow expects that field to contain a value, is that it?

    if yes, then the choice field should be mandatory.. this way the user can't select the option "--SELECT--".. because that option contains no value

     

    You can apply this change on a dataverse level (change column properties to required).. this will make the column always required, both in Portals and Model-Driven App

    Or if you want it to be only mandatory in the Portals.. you can apply Form Metadata and set it required: https://docs.microsoft.com/en-us/powerapps/maker/portals/configure/configure-web-form-metadata

     

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
Fubar Profile Picture

Fubar 74 Super User 2025 Season 2

#2
Jerry-IN Profile Picture

Jerry-IN 55

#3
sannavajjala87 Profile Picture

sannavajjala87 31

Last 30 days Overall leaderboard