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 / 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,471 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,471 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

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 April Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Pages

#1
11manish Profile Picture

11manish 56

#2
Valantis Profile Picture

Valantis 46

#3
rezarizvii Profile Picture

rezarizvii 35

Last 30 days Overall leaderboard