Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics CRM (Archived)

Is there any mechanism of pre-execute in Button click event of CRM?

Posted on by Microsoft Employee

Hi,

I want to execute my javascript code before CRM button function execute. Java script having some coditions. If conditions satisfies, button can continue to execute it's CRM command else it should not execute.

i.e Sales Order --> FulfillOrder button

FulfillOrder opens dialogbox to where user can fulfill the order. I have block of javascript code that contains few conditions that need to be validate before user fulfill the order.

Is there any way to put code and execute it before fulfillOrder fires? If condition(validation) doesn't validate, it should not call fulFillOrder dialogbox.

Can anybody please guide me for above scenario?

*This post is locked for comments

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Is there any mechanism of pre-execute in Button click event of CRM?

    Thanks.

    Here what I tried as you said. In Ribbonworkbench, I have added a Javascript action before FulfillOrder action in Command of Fulfill Order button.

    Command of FulFillOrder.

    1- My Action: Return true/false

    2- Action of fulfill order

    My Action returns true or false based on condition. The point is FulfillOrder action fires even my action return false.

    Please suggest.

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Is there any mechanism of pre-execute in Button click event of CRM?

    Hi Aric,

    Thanks. I have tried by this way. Actully I have replaced CRM command for fulfillOrder button with my command.

    Please let me know what I am missing here

    1- (Replace) Add my customize command on FulFillOrder button in Ribbon.

    2- Command has a function "CheckConditionAndFulfillOrder"

    3- Code sequence of function:

    CheckConditionAndFulfillOrder()

    {

      //check conditions

      fulfillOrder();  

    }

    What I did is replace my function with CRM existing function. CRM function "fulfillOrder()" was working perfectly in CRM 8.0, 8.1 & 8.2. But this function doesn't work in CRM 9.0 as  Microsoft improve security.

    However, I have tried with following function. It works fine in Unmanaged package. But when I check in managed package, it doesn't work.

    var obj = new Sales.SalesOrderRibbonActionsLibrary();

    obj.FulfillOrder();

    Please guide me. I am damn stuck.

  • Aric Levin Profile Picture
    Aric Levin 30,188 on at
    RE: Is there any mechanism of pre-execute in Button click event of CRM?

    You can probably do it using Ribbon Workbench.

    Customize the command, and add a function (your own validation function) to call before the existing function.

    Your function should return true or false, based on condition.

    Not verified with the FullFillOrder, so you should test out in sandbox environment, but I don't see a reason why it would not work.

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Is there any mechanism of pre-execute in Button click event of CRM?

    Hi Hemant,

    I want to execute the code before FulFillOrder action call. Code have some conditions. If conditions satisfied, FulFillOrder dialogbox should appear. If condition doesn't meet, FulFillOrder dialogbox should not appear.

    Please guide

  • Suggested answer
    Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Is there any mechanism of pre-execute in Button click event of CRM?

    Hi,

    I think you should show/hide the fullfil button if your conditions are met or not. Here they are discussing it:

    community.dynamics.com/.../253850

  • Suggested answer
    Hemant Kumar Sahu Profile Picture
    Hemant Kumar Sahu 1,825 on at
    RE: Is there any mechanism of pre-execute in Button click event of CRM?

    Hi Chhaya,

    I guess you want to execute the code before the operation.

    On Save you can call your javascript, this will get triggered before save.

    Hemant

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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,280 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,214 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans