web
You’re offline. This is a read only version of the page.
close
Skip to main content
Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

ExecuteContext is undefined Jscript

(0) ShareShare
ReportReport
Posted on by

Hi there,

I am running a plugin pre-validation to prevent an opportunity and contact being created on lead qualification.

To enhance the user experience I am using the below JavaScript to refresh and open the newly created Account record on save.

However, at present nothing happens...I ran a debugger on the click of qualify and I can see the function being hit but executeContext is undefined...therefore it never gets into the rest of the code and fails the first "if".

function RefreshOnQualify(eventContext) {
debugger;
    if (eventContext != null && eventContext.getEventArgs() != null) {
        if (eventContext.getEventArgs().getSaveMode() == 16) {
            setTimeout(function () {
                Xrm.Page.data.refresh(false).then(function () {
                    var accountId = Xrm.Page.getAttribute("parentaccountid").getValue();
                    if (accountId != null && accountId.length > 0) {
                        Xrm.Utility.openEntityForm(accountId[0].entityType, accountId[0].id)
                    }
                }, function (error) { console.log(error) });;
            }, 3000);
        }
    }
}


Any help appreciated- Am I doing something very silly?

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    RaviKashyap Profile Picture
    55,410 Moderator on at
    RE: ExecuteContext is undefined Jscript

    Are you passing the execution context in the even properties?msdn.microsoft.com/.../gg334332.aspx

  • Andreas Cieslik Profile Picture
    9,267 on at
    RE: ExecuteContext is undefined Jscript

    Whats happening if you but this in the onload?

    Xrm.Page.data.entity.addOnSave(function (context) {

       alert("Form was saved and Save mode is - " + context.getEventArgs().getSaveMode());

    });

    will you get the alert pop up?

  • Verified answer
    Andreas Cieslik Profile Picture
    9,267 on at
    RE: ExecuteContext is undefined Jscript

    Have you selected the pass form context checkbox? It should be.

  • Community Member Profile Picture
    on at
    RE: ExecuteContext is undefined Jscript

    Hi Ravi,

    No I am not passing any parameters - how do I do this?

    Thanks

  • RaviKashyap Profile Picture
    55,410 Moderator on at
    RE: ExecuteContext is undefined Jscript

    Hi clarek,

    You can do this as per the screenshots shared by Andreas. You can find more details in the MSDN article I shared above.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Abhilash Warrier – Community Spotlight

We are honored to recognize Abhilash Warrier as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
HR-09070029-0 Profile Picture

HR-09070029-0 2

#1
UllrSki Profile Picture

UllrSki 2

#3
ED-30091530-0 Profile Picture

ED-30091530-0 1

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans