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 can I pre-populate...
Power Pages
Unanswered

How can I pre-populate a form choice field in a Portal?

(0) ShareShare
ReportReport
Posted on by 34

I am working on a Portal where Contacts associated with an Account should be able to add another Contact - but only to the same Account.

All Contacts are Authenticated users in the Portal. I have created a form where the authenticated user can create a Contact. In this form, the user has to select the Account to associate with the Contact, although the only Account available for selection is the authenticated user's account, as in the attached image.

 

This is error prone. For usability, I would like (OK, need!) the correct Account to be pre-selected in the Account Choice. Ideally in fact I would like the user to be unable to edit this field at all.

 

While it is comparitively easy to pre-populate a Basic Form text field using a snippet of JavaScript, I cannot see how to do this successfully for a Choice. (Note that I can use JavaScript to add text to the Choice, but of course this is not the same as selecting the appropriate value in the Choice field!)

Choice1.pngChoice2.png

Categories:
  • Fubar Profile Picture
    17 Super User 2026 Season 1 on at

    (note: the Account field is a Lookup not a choices field )

     

    If the Account is the same as the Account that the currently logged in user belongs to then I would probably not display the field and set it via the Form's MetaData (see the metadata On Save - to set the Lookup to the the corresponding Lookup field on the logged in Contact record).  

    https://docs.microsoft.com/en-us/power-apps/maker/portals/configure/configure-basic-form-metadata

    (edit: you should also be able to prepopulate using the Prepopulate field see that same link)

     

    If you need to use JavaScript then Lookup fields are set in a similar way but requires the internal GUID and additional values, there is also a slight difference if the Lookup is a Customer or Account Lookup - for a Customer Lookup the last line in the below is required (as the Customer Lookup accepts both contact and account).  

     

     

     

     

     

    $("#customerid").val(accountId);
    $("#customerid_name").val(accountName);
    $("#customerid_entityname").val("account");

     

     

     

     

     

  • Michael_Cullen Profile Picture
    34 on at

    Thanks, @Fubar . It turns out I wasn't able to use the Basic Form Metadata to set the value on the Lookup, but I could use it without difficulty to set a number of the text fields on the form, so it was still very useful!

    I was able to resolve my problem using JavaScript as you suggest:

     

    var accountName = '{{ user.parentcustomerid.Name }}';
    var accountId = '{{user.parentcustomerid.id}}';
    
    $( "#parentcustomerid" ).val( accountId );
    $( "#parentcustomerid_name" ).val( accountName );
    $("#parentcustomerid_entityname").val("account");

     

    For anyone else looking for an answer to a similar problem, I should note that this does not work if I disable the actual #parentcustomerid in JavaScript - I had to disable the buttons for clearing the lookup and for opening the lookup in JavaScript instead.

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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Leaderboard > Power Pages

#1
Mohsin Ali Profile Picture

Mohsin Ali 35

#2
M Bilal Khan Profile Picture

M Bilal Khan 29

#3
11manish Profile Picture

11manish 21 Super User 2026 Season 2

Last 30 days Overall leaderboard