There is a subgrid on a account form that allows you to quick create a contact (contact quick create form). OnLoad of the quick create form, I need to be able to identify what subgrid triggered the quick create form as there are many on the form.
I currently have the javascript as follows that triggers on the contact quick create form onLoad:
function contactQuickCreateFormOnLoad(context)
{
debugger;
//alert("hello world");
var formContext = context.getFormContext();
var control = formContext.getControl();
}
Am I approaching this correctly as I need to get perhaps the name of the subgrid that triggered the quick create form to load? Is this the correct scope?
I ask this because the above code seems to only allow me to see the actual controls on the quick create form. I can't locate any metadata pertaining to the subgrid that triggered this.
Any suggests would be great.
Regards.
As far as I know, you do not get property from which subgrid your quick create form is opened, yes you do get from which parent entity your quick create is opened.
What you could do is customize the button, Add a Js to open your quick create from and there in you can pass parameter.
These parameter values you can you can catch/get in your on load of quick create from
var entityFormOptions = {};
entityFormOptions["entityName"] = "contact";
entityFormOptions["useQuickCreateForm"] = true;
// Set default values for the Contact form
var formParameters = {};
formParameters["firstname"] = "Sample";
formParameters["lastname"] = "Contact";
formParameters["fullname"] = "Sample Contact";
formParameters["emailaddress1"] = "contact@adventure-works.com";
formParameters["jobtitle"] = "Sr. Marketing Manager";
formParameters["donotemail"] = "1";
formParameters["description"] = "Default values for this record were set programmatically.";
// Set lookup column
formParameters["preferredsystemuserid"] = "3493e403-fc0c-eb11-a813-002248e258e0"; // ID of the user.
formParameters["preferredsystemuseridname"] = " Admin user"; // Name of the user.
formParameters["preferredsystemuseridtype"] = "systemuser"; // Table name.
// End of set lookup column
// Open the form.
Xrm.Navigation.openForm(entityFormOptions, formParameters).then(
function (success) {
console.log(success);
},
function (error) {
console.log(error);
});