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)

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

(0) ShareShare
ReportReport
Posted on by

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

I have the same question (0)
  • Suggested answer
    Hemant Kumar Sahu Profile Picture
    1,829 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

  • Suggested answer
    Community Member Profile Picture
    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

  • Community Member Profile Picture
    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

  • Aric Levin - MVP Profile Picture
    30,190 Moderator 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
    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.

  • Community Member Profile Picture
    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.

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