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

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

Add JavaScript to existing button (Ribbon WorkBench 2016)

(0) ShareShare
ReportReport
Posted on by 92

Hello Everyone,

I'm new to ribbon workbench. 

when a user clicks on +new button then it should call my JavaScript.

I have installed Ribbon Workbench 2016.

I Selected Form ribbon, on new button I added new command, called my Js file and published it. 

I'm still not able to trigger my JavaScript file.

please help me to fix this issue.

Thanks in Advance.

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    Abby Kong Profile Picture
    6 on at

    Hi Siddhartha,

    JSaction.png

    'New' button is from MSCRM, are you trying to customize this button? Consider right click on the button to copy and paste it, so you still have this unchanged MSCRM button in your system.  

        

    Can you please check:

    1. If you click on the button, is the command box empty? If  yes ->

    • 1. Create your own or copy New button, or
    • 2.  Right-click on the button and click 'Customise Command' (Not recommended)

    2.  Note down the command behind this button. Open this Command property, make sure you've added a JavaScript Action with js file as well as defined the function name to call JSaction.png

    3.  Make sure ribbons and scripts are published

    Regards,

    Abby

  • Suggested answer
    Mahendar Pal Profile Picture
    45,095 on at

    Hello Siddhartha,

    You can add a custom button and call your scripts there, so in can lead out of the box button hidden, you can check my post here: http://himbap.com/blog/?p=1486

  • Verified answer
    gdas Profile Picture
    50,091 Moderator on at

    Hi Siddartha ,

    Following Step you need to follow after install ribbon workbench.

    - Create one test solution and include your entity , webresource (where you have mentioned on click event) in the solution.

    - Open ribbon workbench , select the solution which you have created .

    - Now go to the area Form , Subgrid  , Home where you want to add your action , find the button.

    - If its existing button then right click on button --Customize Button if its new button then also you can find this options.

    7652.ribbon2.png

    - Now again right click on button just select - Customize Command. You can see the commands in command area highlighted in the above screenshot.

    - Select the command  and mapped web resource and your function.

    7652.ribbon2.png

    - Don't forget to map the command to your button command properties. When you select the button in the Ribbon Workbench you can see command .

    ribbon3.png

    Hope this helps.

  • Siddhartha Challa Profile Picture
    92 on at

    Hi Abby Kong,

    Thanks for your reply.

    Yes I have done all these steps and published it, but it is not calling my Js file.

    I have given my js file as well as function name.

    Here is the screenshot.

    1346.user.png

    Regards,

    Siddhartha.

  • Alex Fun Wei Jie Profile Picture
    33,628 on at

    Hi,

    Please share your js code.

  • Abby Kong Profile Picture
    6 on at

    Hi Siddhartha,

    What is your functions looks like? Does it have any parameters? If you do, please also remember to pass the parameters.

    Also, refresh an opened page with CRTL+F5 after making changes and republish ribbons or js web resource.

    It's best to share the function.

    Or, try with a function really simple to make sure it triggers then replace code back.

    like this function + command in the image give me 

    function setLead(id)
    {
    alert(id);
    }

    3731.alert.png3731.alert.png

    Regards,

    Abby

  • Siddhartha Challa Profile Picture
    92 on at

    Hi Goutam Das,

    Thanks for your reply.

    We can add my custom js file before core js file does it works ?? 

    Regards,

    Siddhartha.

  • Siddhartha Challa Profile Picture
    92 on at

    Hi Wei Jie Fun,

    Its just a normal code which take information from one entity and append the fields info in lead entity when user clicks on +new button

    Regards,

    Siddhartha.

  • Siddhartha Challa Profile Picture
    92 on at

    Hi Abby Kong,

    This is Javascript function. I'm calling this from js file from Ribbon Workbench 

    function setLead() {
    var userId = Xrm.Page.context.getUserId();

    userId = userId.replace(/[{}]/g, "");

    alert(userId);
    }

    Regards,

    Siddhartha.

  • Verified answer
    Abby Kong Profile Picture
    6 on at

    Hi Siddhartha,

    It's strange. I tested your code, it actually works for me.  Below is the screenshot of ribbon workbench and result. My user id does show in an alert, and after I close the alert popup, the new form is opened up. 

    1754.result.png

    1754.result.png

    Is the script web resource published after changed? If you add same JS Action to a command created by yourself, will it trigger?

    Regards,

    Abby

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…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
SA-08121319-0 Profile Picture

SA-08121319-0 4

#1
Calum MacFarlane Profile Picture

Calum MacFarlane 4

#3
Alex Fun Wei Jie Profile Picture

Alex Fun Wei Jie 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans