
The business requirement is to create an account on qualification of a lead.
As most people may be aware there has been major changes to the lead qualifications process from 2011 to 365.
After serious thought, I opted to create a pre-validation plugin and then some JavaScript to redirect the user to the newly created account after qualify. This works as a nice end to end solution.
Although slightly different to my requirement, I used the following link to develop my idea- https://www.thrives.be/dynamics-crm/functional/lead-qualification-well-skip-that-opportunity/
This works fantastically well however, ONLY after the first qualify of the day....
On the first qualify, the lead page remains and does not redirect the user, if you click qualify again...an error comes up to say "Already Qualified" and then redirects the user to the account page.
I am guessing this is todo with the JS timeout and the qualify code only waking up for the first time.
Help much appreciated.
*This post is locked for comments
I have the same question (0)Hi,
if could be the delay, in which case you might just try to alter the code like this:
var refreshCounter = 0;
function OpenAfterRefresh()
{
Xrm.Page.data.refresh(false).then(function () {
var contactId = Xrm.Page.getAttribute("parentcontactid").getValue();
if (contactId != null && contactId.length > 0) {
Xrm.Utility.openEntityForm(contactId[0].entityType, contactId[0].id)
}
else{
refreshCounter++;
if(refreshCounter < 10) setTimeout(function () {
OpenAfterRefresh();
}, 500);
}
}, function (error) { console.log(error) });;
}
function RefreshOnQualify(eventContext) {
if (eventContext != null && eventContext.getEventArgs() != null) {
if (eventContext.getEventArgs().getSaveMode() == 16) {
refreshCounter = 0;
setTimeout(function () {
OpenAfterRefresh();
}, 500);
}
}
}