Skip to main content

Notifications

Community site session details

Community site session details

Session Id :
Power Pages - General Discussions
Unanswered

Conditionally predefault choice/dropdown column

(0) ShareShare
ReportReport
Posted on by 309

Hi,

 

We have a dropdown/choice field on a basic form. We have passed a URL parameter to the page and in the Additional Settings of the Basic Form, we have added the following code.

prathyoo_0-1708602106750.png

 

  var regType = '{{ request.params.evttype }}'; $("#dgccso_registrationtype").val(regType).change();  

The code works and the correct value shows up on the form. When the form is submitted, the value that was assigned to the column is correctly updated on the record that is created.

 

But, we want to either hide this form field or make it read-only. But, when we do that, the column value is not updated in dataverse -

prathyoo_1-1708601639182.png

The first record is where we tried to disable the column on the UI by using the following JS - 

 

 $("#dgccso_registrationtype").attr("disabled","disabled"); 

 

We also tried making the column read-only on the dataverse form (not the portal basic form). Again, the column becomes blank even though we have predefaulted it via code.

 

We also tried removing the column from UI using JS and again after removing from UI, the field does not get update when the form is submitted but becomes blank instead.

$("#dgccso_registrationtype").remove()

 

What is the way to have the column read-only/hidden but yet updated on form submission?

  

 

 

 

 

 

Categories:
  • Fubar Profile Picture
    7,960 Super User 2025 Season 1 on at
    Re: Conditionally predefault choice/dropdown column

    First, if the field is Readonly on the in Dataverse Form, then it will not update back.

    To hide it.

     

    $("#field_name").closest("td").find("div.control, div.info").hide();

     

    The above is from @OliverRodrigues Some other show/hide by Oliver here https://oliverrodrigues365.com/2020/07/19/power-apps-portals-javascript-tip-01-hide-show-elements/

     

    Can't remember if this will work or not, but try making the control readonly (rather than disabled), see the "Set Dropdown ReadOnly" on this other page by Oliver https://oliverrodrigues365.com/2020/08/16/power-apps-portals-javascript-tip-02-set-attributes-read-only/

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 >