Skip to main content

Notifications

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

  • Siddhartha Challa Profile Picture
    92 on at
    RE: Add JavaScript to existing button (Ribbon WorkBench 2016)

    Hi Abby Kong,

    thanks for reply.

    Yes Abby now I'm able to trigger my javascript.

    Is the script web resource published after changed?

    yes.

    Regards,

    Siddhartha.

  • Verified answer
    Abby Kong Profile Picture
    6 on at
    RE: Add JavaScript to existing button (Ribbon WorkBench 2016)

    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

  • Siddhartha Challa Profile Picture
    92 on at
    RE: Add JavaScript to existing button (Ribbon WorkBench 2016)

    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.

  • Siddhartha Challa Profile Picture
    92 on at
    RE: Add JavaScript to existing button (Ribbon WorkBench 2016)

    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
    RE: Add JavaScript to existing button (Ribbon WorkBench 2016)

    Hi Goutam Das,

    Thanks for your reply.

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

    Regards,

    Siddhartha.

  • Abby Kong Profile Picture
    6 on at
    RE: Add JavaScript to existing button (Ribbon WorkBench 2016)

    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

  • Alex Fun Wei Jie Profile Picture
    33,626 on at
    RE: Add JavaScript to existing button (Ribbon WorkBench 2016)

    Hi,

    Please share your js code.

  • Siddhartha Challa Profile Picture
    92 on at
    RE: Add JavaScript to existing button (Ribbon WorkBench 2016)

    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.

  • Verified answer
    gdas Profile Picture
    50,091 Moderator on at
    RE: Add JavaScript to existing button (Ribbon WorkBench 2016)

    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.

  • Suggested answer
    Mahendar Pal Profile Picture
    45,095 on at
    RE: Add JavaScript to existing button (Ribbon WorkBench 2016)

    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

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

Announcing the Engage with the Community forum!

This forum is your space to connect, share, and grow!

🌸 Community Spring Festival 2025 Challenge Winners! 🌸

Congratulations to all our community participants!

Adis Hodzic – Community Spotlight

We are honored to recognize Adis Hodzic as our May 2025 Community…

Leaderboard > Microsoft Dynamics CRM (Archived)

#1
Mohamed Amine Mahmoudi Profile Picture

Mohamed Amine Mahmoudi 83 Super User 2025 Season 1

#2
Community Member Profile Picture

Community Member 54

#3
Victor Onyebuchi Profile Picture

Victor Onyebuchi 6

Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans