Hi,
I have a web form which create the record for the 'Application' entity, I then have one more steps with a subgrid to the related child entity "Requests" i.e. 1 application can have more than 1 request. In this steps, I have added the metadata for the subgrid and added the create button which open the Entity Form for Create Request.
How would I pre populate the Application lookup on the qhile creating the Request record from the subgrid.
*This post is locked for comments
Hi Gaurav,
When you create a record from a subgrid, it automatically gets associated with the main record on save.
Hope this helps.
Hi Ravi,
I do have a similar requirement where in I need to populate the lookup field in save and need not to show on the form.
Can you please explain how did you relate the parent record with the grid settings?
Agreed with Ravi that this functionality is indeed OOB. Just wanna elaborate a bit more so that it's clear for anyone else experiencing this issue.
The parent lookup field (in Ravi's case "Application") appears to be not pre-populating i.e. is empty when the popup opens up. However, if you remove the lookup field from the entity form and try to create the related record, the application id does get saved (in the background) and the record gets associated with the parent record i.e. "application".
I think if you need to show the lookup pre-populated (which probably is a good idea) you would need to use the value from the parameters as explained in the other response.
Thanks Arpit. Thanks for sharing the above workaround.
However, in my case, I observed that the lookup was populating by itself i.e. when user was adding the record in the subgrid, those records are automatically sets the parent look. I guess this is because in the subgrid i have used the the source as related record for the subgrid (I may be wrong).
Hi Ravi,
We also had the similar requirement but unfortunately, we couldn't find any OOB way to achieve this.
I can suggest you one alternative solution, that I had tried to achieve this:
1. Onload of Application Entity Form- Get the Application Record Guid (Can get it from the query string, see code below) and Application Record Name (Can get it from Application Entity Form itself). And then Store both the values in local storage/session.
Let say your Application Web page URL is:
// Get Id parameter value from query string
function getParameterByName(name, url) {
if (!url) url = window.location.href;
name = name.replace(/[\[\]]/g, "\\$&");
var regex = new RegExp("[?&]" + name + "(=([^&#]*)|&|#|$)"),
results = regex.exec(url);
if (!results) return null;
if (!results[2]) return '';
return decodeURIComponent(results[2].replace(/\+/g, " "));
}
var applicationRecordGuid = getParameterByName('id'); // "id"
See to get/set value in Local Storage:
https://www.w3schools.com/html/html5_webstorage.asp
2. Now onload of your subgrid record form (Request form), get the Guid from local storage and auto-populate it in the Application lookup field.
$("attribute_name").attr("value","Name");
$("arrtibute_id").attr("value","attribute_GUID");
$("#attribute_entityname").attr("value","entity_name");
Hope you understood.
If you find the answer useful, please mark it as verified
Cheers
Arpit
https://arpitmscrmhunt.blogspot.in
Stay up to date on forum activity by subscribing. You can also customize your in-app and email Notification settings across all subscriptions.
André Arnaud de Cal... 291,253 Super User 2024 Season 2
Martin Dráb 230,188 Most Valuable Professional
nmaenpaa 101,156