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 main form p...
Power Pages
Unanswered

JavaScript main form prepopulates field but does not save the value to the dataverse

(0) ShareShare
ReportReport
Posted on by

I have a main form which is the parent record I select the create child record button and the child form appears correctly with the Name field prepopulated from the Parent record. However when I save the child record with the prepopulated Name field and other fields all the form fields save to the Dataverse excepts for the prepopulated one.

The prepopulated field is pulling from a lookup on the parent record

I am attempting to prepopulate  the Name field on the child record with just the text from the lookup that is working but it just won’t save to the dataverse upon submit on the form.

Categories:
I have the same question (0)
  • Inogic Profile Picture
    1,297 Moderator on at

    Hi @mjackson122 ,

     

    As per our understanding you are seeking to prepopulating parent record and associate a child record with its parent record upon saving,

     

    If you have configured the "subgrid" type of "Basic metadata" in the parent form for the "child create form" within the portal, it generally works well. Child records are created within the context of their parent record. However, during the creation of the child record, parent lookup field will be left empty, the association with the parent record only occurs after saving in the background.

     

    It appears that there may have been a change in the approach to updating the child record upon saving, possibly involving prepopulating the parent name on the child record.

    However, achieving this requires following specific steps.

     

    For more detailed guidance, please refer to the forum question provided below:

     

    https://powerusers.microsoft.com/t5/General-Discussions/Form-create-incident-Get-automatically-Customer-an-Contact/m-p/2372514#M4689

    Thanks!

    Inogic Professional Services Division

    Power Platform and Microsoft Dynamics 365 CRM Development – All under one roof!

    Drop an email at crm@inogic.com

    Services:  http://www.inogic.com/services/

    Power Platform/Dynamics 365 CRM Tips and Tricks:  http://www.inogic.com/blog/



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

    @mjackson122 a few points here:

     

  • mjackson122 Profile Picture
    on at

    Yes that is correct I have a subgrid (child) where when I hit create new the child form appears and the name column is properly populated with name column from the parent record. However upon hitting save the child record retains all fields except the prepopulated lookup. My preference is to complete this task with just JS but I have yet to come across a successful method for that.

     

    Here is my web template code:

    {% assign caseticket = entities["ustpbppd_ustpbppdebtentity"][request.params.id] %}

     

    <div class= "hidden">

     

    <!--goes under div hidden-->

    <p id = "entityName" > {{caseticket.ustpbppd_name}}</p> <!--logical name of parent table name column with  lookup field on it-->

    <p id = "entityID"> {{caseticket.ustpbppd_ustpbppdebtentityid}} <p> <!--logical name of parent table unique ID (GUID) column-->

    <p id = "entityEntityName"> {{"ustpbppd_ustpbppdebtentity"}}<p> <!--logical name of parent table with lookup field on it-->

    </div>

     

    <div id="mainContent" class = "wrapper-body" role="main">

     

        {% block main %}

        {% include 'Page Copy' %}

     

         {% include 'Child Navigation' showdescriptions: true %}

        {% if page.adx_entitylist %}

        {% include 'entity_list' key: page.adx_entitylist.id %}

        {% endif %}

     

        {% if page.adx_entityform %}

        {% entityform id: page.adx_entityform.id %}

        {% endif %}

     

        {% if page.adx_webform %}

        {% webform id: page.adx_webform.id %}

        {% endif %}

        {% endblock %}

    </div>

     

    Here is my javascript

     

    $(document).ready(function(){

        let entityName = window.parent.$('#entityName').text();

        let entityID = window.parent.$('#entityID').text();

        let tableName = window.parent.$('#entityEntityName').text();

     

        $("#ustpbppd_ustpbppdebtentity_name").val(entityName);

        $("#ustpbppd_ustpbppdebtentity_name").attr("value",entityName);

        $("#ustpbppd_ustpbppdebtentity").attr("value",entityID);

     

        $("#ustpbppd_ustpbppdebtentity_entityname").attr("value",tableName);

     

        });

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

    I am a bit confused with below code. You should have only 1 elements to update the value, which one is your child table primary name column?

     

    I feel like the first line of code below is all you need, also, can you make sure the fields is NOT set as read-only in the Dataverse form? 

     

     $("#ustpbppd_ustpbppdebtentity_name").val(entityName);
     $("#ustpbppd_ustpbppdebtentity_name").attr("value",entityName);
     $("#ustpbppd_ustpbppdebtentity").attr("value",entityID); 
     $("#ustpbppd_ustpbppdebtentity_entityname").attr("value",tableName);

     

  • mjackson122 Profile Picture
    on at

    It is a lookup field I am pulling from to prepopulate a name (primary column) on another table according to Microsoft you need the lookups the following parameters for lookup

     

    logical name of table

    logical primary name on the table

    logical unique id of the table

    This is what I was following  https://youtu.be/tn3mszNfu5s?si=pQk7XQjxu44fJXop

     

    however the field loads properly in the form but upon hitting save the dataverse is empty for that columns

  • fm_skeller Profile Picture
    277 Moderator on at

    It looks as though there is a space after each of the <p> elements you are using?

    <p id = "entityName" > {{caseticket.ustpbppd_name}}</p>

    could you try this instead:

    <div class= "hidden">
    <!--goes under div hidden-->
    <p id = "entityName" >{{caseticket.ustpbppd_name}}</p> <!--logical name of parent table name column with lookup field on it-->
    <p id = "entityID">{{caseticket.ustpbppd_ustpbppdebtentityid}} <p> <!--logical name of parent table unique ID (GUID) column-->
    <p id = "entityEntityName">{{"ustpbppd_ustpbppdebtentity"}}<p> <!--logical name of parent table with lookup field on it-->
    </div>

    In addition, if you are using the default actions configuration for the entitylist, usually the parent record is included in the URL of the modal dialog and you can access those values with the liquid request object (Available Liquid objects | Microsoft Learn).

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

    Hi, apologies, I understood it was the primary column of the child table.

    If this is a subgrid and you want to populate the lookup with the parent, you should NOT use JavaScript. This is OOB behaviour of the platform, when adding an item in a subgrid, that relationship is automatically set.

    On the dataverse form, make sure you have selected "Show Related Records" when adding the subgrid:

    OliverRodrigues_0-1705607926733.png

     

  • mjackson122 Profile Picture
    on at

    I just reverted back to the OOTB but there are instances where the user may now want to scroll all the way to the top of the page to look at the Parent value. That's why I wanted it to prepopulate on the form and save to the primary column in the child table

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

    You mentioned it was populating with JS but not saving, most likely cause of this (assuming it is text in a text field) is that on the Dataverse Form you have the target field marked as readonly (when the form is submitted fields that are configured as readonly on the dataverse form do not get saved - this would be considered bad practice, as only data that is expected to be populated should be received and saved), if this is the case the work around is to make the field editable on the dataverse form, but then make it readonly on the portal via JS.

     

    Also, you can configure a Quick View form in dataverse on the parent record with fields you want to display, then add the quick view form to your child records form (linked to the parent record Lookup) and display info (readonly) from the parent record. Then when the form is submitted update the Name field via a realtime workflow.

     

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

Congratulations to the July Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Pages

#1
Mohsin Ali Profile Picture

Mohsin Ali 33

#2
sannavajjala87 Profile Picture

sannavajjala87 28 Super User 2026 Season 2

#3
11manish Profile Picture

11manish 22 Super User 2026 Season 2

Last 30 days Overall leaderboard