Hello everyone,
I need some help from you guys on the code mentioned below. The requirement is that there is a button on the account form, on clicking of which a new quick create case form must be opened. I have written the code and tried implementing it using ribbon benchwork. but I am not getting the desired results. Please help me with the same.
function myFunction()
{
debugger;
var account = Xrm.Page.getAttribute("to");
var accountValue = account.getValue();
if (accountValue != null)
{
var accountId = accountValue[0].id;
}
var parentAccount = {entityType: "account", id: accountId};
var parameters = { title: Xrm.Page.getAttribute("new_casetitle").getValue(), description: Xrm.page.getAttribute("description").getValue()};
Xrm.Utility.openQuickCreate("incident", parentAccount, parameters).then(function (lookup) { successCallback(lookup); }, function (error) { errorCallback(error);});
}
function successCallback(lookup)
{
alert("lookup: " + lookup.savedEntityReference.id);
alert("lookup: " + lookup.savedEntityReference.name);
}
function errorCallback(e)
{
// *** No new contact created, which is an error we can ignore!
alert("Error: " + e.errorCode + " " + e.message);
}