cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Eagle0473
Frequent Visitor

Set default value in field Subject of web form create case

Hi all ,

 

I have create a customer powerapps portal and I want set , with a default value , the field subject .

The Subject is a lookup field type .  I create a basic form metadata , but the field not populated ! 

 

How I do it ?

 

Thanks 

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
mbayes
Resolver I
Resolver I

Hey Eagle,

 

Unfortunately you cannot set a lookup field in the "Prepopulate" area of the metadata record.

This is due to the fact that a lookup field is broken into 3 parts - ID, Name, and EntityType.

 

You will have to write Javascript to prepopulate the field on-load. In order to do this, you should be able to locate the Custom Javascript section on the Entity Form/Web Form itself (or web page depending on requirement) and add something in the following format:

$(document).ready(function(){
     $("#" + Schema + "_name").val(Name);
     $("#" + Schema).val(GUID);
     $("#" + Schema + "_entityname").val(EntityName);
});

You will need to populate the Name of the record into the name field, the GUID of the record, as well as the entity name (schema name).

 

The easiest route is to pass these as parameters in your form request url and retrieve them in javascript. If that isn't an option, you can always hard-code them in, or use a FetchXml block in a web template to retrieve the associated record to populate.

If you need further clarification let me know!

Thanks!

 

Matt Bayes

View solution in original post

6 REPLIES 6
hardikv
Memorable Member
Memorable Member

Hi @Eagle0473 

 

Are you using Basic Form or Advanced Forms?

Can you please let us know that subject lookup field is reference to which entity?

 

Please refer this blog:

https://dynamicsofdynamicscrm.com/2020/05/29/no-code-way-pre-populate-date-field-to-current-date-in-...

 

mbayes
Resolver I
Resolver I

Hey Eagle,

 

Unfortunately you cannot set a lookup field in the "Prepopulate" area of the metadata record.

This is due to the fact that a lookup field is broken into 3 parts - ID, Name, and EntityType.

 

You will have to write Javascript to prepopulate the field on-load. In order to do this, you should be able to locate the Custom Javascript section on the Entity Form/Web Form itself (or web page depending on requirement) and add something in the following format:

$(document).ready(function(){
     $("#" + Schema + "_name").val(Name);
     $("#" + Schema).val(GUID);
     $("#" + Schema + "_entityname").val(EntityName);
});

You will need to populate the Name of the record into the name field, the GUID of the record, as well as the entity name (schema name).

 

The easiest route is to pass these as parameters in your form request url and retrieve them in javascript. If that isn't an option, you can always hard-code them in, or use a FetchXml block in a web template to retrieve the associated record to populate.

If you need further clarification let me know!

Thanks!

 

Matt Bayes

Eagle0473
Frequent Visitor

Hi Matt , thank for replay .

I insert this script in this position of the web form ?

 

Eagle0473_0-1634546261509.png

 

 

 

Hi , thank you for replay .

I tryed this solution , but unfortunetly for subject field not work 

 

 

@Eagle0473

 

You need to insert the script on the portal basic form JavaScript not as per your screenshot. 

Another alternative is to use Web api as per the below article:

https://imperiumdynamics.com/blog/Populating-a-lookup-on-Power-App-Portals

 

If this post helps you with your problem, please mark your as Accepted solution.If you like my response, please give it a Thumbs Up.

Blog: here

Hi @mbayes , solved !

Thank you so much

Helpful resources

Announcements
Microsoft 365 Conference – December 6-8, 2022

Microsoft 365 Conference – December 6-8, 2022

Join us in Las Vegas to experience community, incredible learning opportunities, and connections that will help grow skills, know-how, and more.

MPP IDEAS updated 768x460.png

Ideas

Discover ideas and concepts from users like you for how to use Power Pages and take your work to the next level.

Top Solution Authors
Users online (2,836)