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 Apps / Auto-Populate field Po...
Power Apps
Suggested Answer

Auto-Populate field Power Pages

(3) ShareShare
ReportReport
Posted on by 82
Hi all, I have a Donors table and Donations Table. In power pages, when a donor logs in and clicks on Donate button, it displays a donation form.
 
I have lookup columns between the tables to identify who has donated etc. (Donors column from Donor table and Donor ID from Donations table) How can I get Donor ID to auto-populate?
  • Jon Unzueta Profile Picture
    1,836 Super User 2026 Season 1 on at
    To automatically populate the donor ID in the donation form on Power Pages, you can follow these steps:
     
    Steps to Automatically Populate the Donor ID

    Configure the Relationship Between Tables:
    Ensure that the Donors and Donations tables are correctly related through a lookup column. The Donations table should have a lookup column that relates to the Donors table.
    Create the Donation Form:
    In Power Pages, create an edit form for the Donations table. This form will be used for donors to enter their donations.
    Obtain the Donor ID:
    When the donor logs in, obtain their donor ID. This can be done using the User() function to get the user's email and then looking up the donor ID in the Donors table.
    Configure the Form to Populate the Donor ID:
    Configure the donation form so that the donor ID field is automatically populated using the obtained ID.
    Implementation Example
    Step 1: Configure the Relationship Between Tables
    Ensure that the lookup column in the Donations table is correctly configured to relate to the Donors table.
    Step 2: Create the Donation Form
    In Power Pages, add an edit form for the Donations table.
    Step 3: Obtain the Donor ID
    Use the User() function to get the current user's email.
    Use a gallery or a collection to look up the donor ID in the Donors table.
    Step 4: Configure the Form to Populate the Donor ID
    Configure the donor ID field in the donation form to automatically populate with the obtained ID.
    Implementation Details
    Create a Collection for the Current Donor:
    On the start screen or the screen where the donation form is displayed, create a collection to store the current donor's information.
    Configure the Donation Form:
    In the donation form, select the donor ID field.
    In the Default property of the donor ID field, set the value to automatically populate with the current donor's ID.
    Complete Example
    Create the Collection on the Start Screen:

    Configure the Donation Form:
    In the donation form, select the donor ID field.
    In the Default property of the donor ID field, set the value:
    Considerations
    Security: Ensure that only authenticated users can access their own data and make donations.
    Permissions: Verify that the table permissions are correctly configured to allow reading and writing data as needed.
    If you need more details or help with any specific step, feel free to ask. I'm here to help!
     
     
    If I have helped you, please mark the answer as accepted and/or give me a like, thank you very much!
  • Suggested answer
    Rishabh_Pathak Profile Picture
    10 on at
    Hi,
     
    You can achieve this in two ways:
    1. Basic Form Metadata (Recommended / No-Code):
    - Open the Power Pages Management app.
    - Go to Basic Forms (or Advanced Form Step) and open your Donations Form.
    - Under the Basic Form Metadata tab, click "+ New Basic Form Metadata".
    - Set Type to "Attribute" and select your Donor lookup field.
    - Under Prepopulate Field: set to "Yes", Type = "Current Portal User", From Attribute = "Contact".
    - Set "Set Value On Save" to "Yes" and "Read Only" to "Yes".
    - Save, clear portal cache, and test.
     
    2. JavaScript + Liquid (If custom table / custom logic is needed):
    Add this code into the Custom JavaScript section of the Basic Form:
    $(document).ready(function () {
        var userId = "{{ user.id }}";
        var userName = "{{ user.fullname }}";
        var lookupField = "#new_donorid"; // Replace with your lookup logical name
        if ($(lookupField).length && userId) {
            $(lookupField).val(userId);
            $(lookupField + "_name").val(userName);
            $(lookupField + "_entityname").val("contact");
            $(lookupField + "_name").prop("disabled", true);
            $(lookupField).closest(".control").find(".btn-lookup").hide();
        }
    });
     
    Note: Make sure your Web Role has valid Table Permissions configured for both tables.
  • Suggested answer
    M Bilal Khan Profile Picture
    1,172 on at

    Hi @PowerDigitize_1

    If the goal is to automatically populate the Donor lookup on the Donation form with the currently logged-in donor, Power Pages has a built-in configuration for this.

    Since the donor is the authenticated Power Pages user, you can configure the Donation Basic Form to populate the lookup from the current portal user.

    In Portal Management → Basic Form → Additional Settings, configure:

    • Target Attribute Logical Name: your Donation table's donor lookup column
    • Populate Lookup Field: Yes
    • Source Type: Current Portal User
    • Reference Table: Donor/Contact table, depending on how your data model is set up

    Microsoft documents this specifically for lookup fields: the Populate Lookup Field option can retrieve the current authenticated user's contact record and populate the lookup on the form.

    For example, if your structure is:

    Donor
     └── Donor ID / Contact
    
    Donation
     └── Donor (Lookup → Donor)
    

    and the Power Pages user is associated with that Donor record, the Donation form can automatically set:

    Donation.Donor = Current logged-in user's Donor/Contact
    

    This is preferable to exposing the Donor ID in the URL or asking the user to select themselves manually.

    There is also a Prepopulate field configuration in Basic Form Metadata. If the lookup is based directly on the logged-in user's Contact, you can use Current User's Contact as the source. Microsoft documents this as a supported prepopulation option.

    One important thing to check is your relationship/model:

    If Donor is actually the Contact table:
    Use the current Power Pages user's Contact directly.

    If Donor is a custom Dataverse table:
    Make sure there is a relationship between the Contact (Power Pages user) and the Donor record. Then configure the lookup population against that relationship rather than trying to pass a raw Donor ID from the browser.

    Also make sure the appropriate table permissions and web roles are configured, since Power Pages forms respect Dataverse/Power Pages security configuration.

    So in this case, I would try the built-in Populate Lookup Field → Current Portal User approach first before writing JavaScript.

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 Apps

#1
11manish Profile Picture

11manish 221 Super User 2026 Season 2

#2
WarrenBelz Profile Picture

WarrenBelz 188 Most Valuable Professional

#3
Mohsin Ali Profile Picture

Mohsin Ali 120

Last 30 days Overall leaderboard