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 could i prefill a ...
Power Pages
Answered

how could i prefill a basic form in insert mode

(0) ShareShare
ReportReport
Posted on by 80

Hello,

I created a page which contains a basic form in insert mode. i need to prefill the fields on the form when it's loaded.

How could i do it?

Thanks.

Regards.

 

Categories:
I have the same question (0)
  • natalya Profile Picture
    133 on at

    I believe you can use JavaScript for it or by setting default values.

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

    @NatGeo answer is correct, can you give more details of your requirement? you need to apply JS basically

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

    @cdamy were you able to solve your problem? do you need any more info? 

  • CDamy Profile Picture
    80 on at

    Hi 

    Thanks for your responses. @OliverRodrigues i created a list and two forms(one in insert mode and second in edit mode). My entitylist is linked to opportunities list. I added on it a menu actions with some action to edit another custom entity.Which has these forms. Now by default the basic form in insert mode open empty. I want to prefill some fields. So you told to put some javascript. Where? in form on load event in crm inside. or in portal inside?

    Thanks.

    Regards.

  • natalya Profile Picture
    133 on at

    Hi @cdamy,

    you can use Web Page -> localized content->Advanced (for CSS, JavaScript)

     

  • CDamy Profile Picture
    80 on at

    Hello NatGeo,

    Thanks. So i should use webapi to retrieve item dataverse and set the values into my forms?

  • natalya Profile Picture
    133 on at

    Hi @cdamy ,

    If you have to assign values to fields from another table, then it is getting more complex.

    You have to retrieve data and assign values using (FetchXml, Liquid and some JavaScript).

    Please explain more what you are trying to achieve.

     

  • CDamy Profile Picture
    80 on at

    Hello @NatGeo ,

    Thanks for your response, As i explained to @OliverRodrigues . I created an entitylist of opportunities and i added some actions to them. One action consist to open a  new form of custom entity called "visit". So i created a basic form linked to this entity form in dataverse. But my basic form is in insert mode. The form contains two lookup fields, and other fields . One lookup is linked to table contact which is the opportunity contact and the second is linked to opportunity.

    I pass through the webpage the querystring which contains the id of the opportunity select into the list.

    Is it clear? or i should send you some screenshot?

    Ps: You suggest to use only liquid and js without calling webapi or REST(odata,..)?

     

     

     

  • natalya Profile Picture
    133 on at

    From explanations you provided, I am not sure there is a way to set a default value for a lookup(s) (if I understood correctly, your requirments). I see that you can only populate the lookup with certain set of records, based on UserID or any other ID.

    As for populating lookups you have to use Web template to retrieve some data (this is your webAPI),  FetchXml.  JS - is for assigning values for lookup (Web Page). 

  • CDamy Profile Picture
    80 on at

    @NatGeo , When talk about WebApi, it's related to xrm webservice call(REST).

    So, if i understood. I just have to create a webtemplate and in this webtemplate i make liquid fetch query into this code i create script to populate my form. Lilke this:

    {%assign opportunityid=request.params["id"]%}

    {%fetchxml opportunities%}

    <fetch>

    <attribute...>

    <filter>

    <condition attribute="opportunityid"  operator="eq" value = "{{opportunityid}}"..>

     

    </filter>

    <endfetch>

    {%endfetchxml%} 

    {%for myopportunity in .......%}

    <script>

    //should i populate lookup here  like this??

    $("#...").attr("value", {{myopportunity.contact.name}});

     

     

    </script>

    {%endfor%}

     

    Thanks

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

These are the community rock stars!

Leaderboard > Power Pages

#1
rezarizvii Profile Picture

rezarizvii 61

#2
oliver.rodrigues Profile Picture

oliver.rodrigues 40 Most Valuable Professional

#3
11manish Profile Picture

11manish 30

Last 30 days Overall leaderboard