Hello All,
I am trying to open the quick create form, from the UCI forms, but it is always opening the default main form. Its working well from the classic web forms. Below is the code i m trying to use. Please let me know in case if i am missing any thing or there is some other way of doing it.
The environment is - Version 1710 (9.1.0.4437) online.
var entityFormOptions = {};
entityFormOptions["entityName"] = "msdyn_payment";
entityFormOptions["useQuickCreateForm"] = true;
entityFormOptions["formId"] = "62F07FB4-A0AC-4312-A22A-0768E4C6BB86";
var formParameters = {};
formParameters["hsl_case"] = formContext.data.entity.getId();
formParameters["hsl_casename"] = formContext.data.entity.getPrimaryAttributeValue();
//Xrm.Utility.openQuickCreate("msdyn_payment", parentCase , formParameters).then(
Xrm.Navigation.openForm(entityFormOptions , formParameters).then(
function (success) {
Xrm.Utility.alertDialog(success.message);
console.log(success);
},
function (error) {
console.log(error);
});
Hi partner,
If you want to pass "primary control" in ribbon, you should add it as a parameter in ribbonworkbench command.
I tried almost the same code in my sales hub (I don't have "hsl_case" lookup field in my account form so I annotated them) and it worked well after add the CRM parameter to ribbon command.
Hope it helps.
Best Regards,
Leo
Hello Leo,
thank you very much for your suggestion, i tried the above way,
function addPayment(primaryControl)
{
debugger;
var formContext = null;
if(isValid(primaryControl))
formContext = primaryControl.getFormContext();
else formContext = primaryControl;
// Set default values for the Contact form
var parentCase = {
entityType: "incident",
id: formContext.data.entity.getId().replace("{","").replace("}","")
};
var entityFormOptions = {};
entityFormOptions["entityName"] = "msdyn_payment";
entityFormOptions["useQuickCreateForm"] = true;
entityFormOptions["formId"] = "62F07FB4-A0AC-4312-A22A-0768E4C6BB86";
var formParameters = {};
formParameters["hsl_case"] = formContext.data.entity.getId();
formParameters["hsl_casename"] = formContext.data.entity.getPrimaryAttributeValue();
//Xrm.Utility.openQuickCreate("msdyn_payment", parentCase , formParameters).then(
Xrm.Navigation.openForm(entityFormOptions , formParameters).then(
function (success) {
Xrm.Utility.alertDialog(success.message);
console.log(success);
},
function (error) {
console.log(error);
});
}
function isValid(primaryControl)
{
debugger;
var isValidPrimaryControl = false;
try {
var myControl = primaryControl.getFormContext();
isValidPrimaryControl = true;
}
catch (e)
{
isValidPrimaryControl = false;
}
return isValidPrimaryControl;
}
but still in the same loop.
Actually this code is being called from the click of a button.
Hope you catch the issue in the above code.
Hi partner,
I've updated your code here.
function openCF(executionContext) { var formContext=executionContext.getFormContext(); var entityFormOptions = {}; entityFormOptions["entityName"] = "msdyn_payment"; entityFormOptions["useQuickCreateForm"] = true; entityFormOptions["formId"] = "62F07FB4-A0AC-4312-A22A-0768E4C6BB86"; var formParameters = {}; formParameters["hsl_case"] = formContext.data.entity.getId(); formParameters["hsl_casename"] = formContext.data.entity.getPrimaryAttributeValue(); //Xrm.Utility.openQuickCreate("msdyn_payment", parentCase , formParameters).then( Xrm.Navigation.openForm(entityFormOptions, formParameters).then( function (success) { Xrm.Utility.alertDialog(success.message); console.log(success); }, function (error) { console.log(error); }); }
In UCI, we should declear "formContext" by using "executioncontext.getFormContext".
For example, I want to open quickCreate form of Account in UCI, the code I've changed could work well.
Remember to select "Pass execution context as first parameter" when adding function to Onload event.
Hope it helps.
Best Regards,
Leo
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,240 Super User 2024 Season 2
Martin Dráb 230,149 Most Valuable Professional
nmaenpaa 101,156