Just imagine that you need to define the context in which “Quick Create Form” was opened and depending on the context – to do some additional operations. In this short post I provide supported code you can use to define it.
Create JavaScript webresource and add following code inside:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
function quickCreateOnLoad(){ //this variable contains entity reference to the parent record var parentRecordReference = Xrm.Utility.getPageContext().input.createFromEntity; //if this variable is null then Quick Create Form was called from the Global Menu //or from some other code without setting the parent record context if (parentRecordReference == null){ return; } //you can use value of parentRecordReference in your code console.log(parentRecordReference.id); console.log(parentRecordReference.entityType); console.log(parentRecordReference.name); } |
Add this webresource to the “Quick Create Form” and register quickCreateOnLoad to handle OnLoad event of the form.
Is this code supported with Dynamics 365 v9?
Hello,
This code should work fine for Online and UCI but I’m not fully certain that it’ll work for the on-prem and classic UI.
Andrew
Thanks, this code “Xrm.Utility.getPageContext().input.createFromEntity” doesn’t work if the parent form is in new mode. Is there a way to directly get the context of the parent form from the child quick create?
That is a great question and I have no idea. What information in particular do you want to get from the parent record that was not created yet?