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

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Customer experience | Sales, Customer Insights,...
Answered

Inject Javascript dependency inside a custom ribbon button

(0) ShareShare
ReportReport
Posted on by

Hey guys, 

this is a pretty specific question. 

Javascript A: 

function onclick() {
    test();
}

Javascript B: 

function test() {
 alert ('works');
}

I have custom Ribbon Button Test which is configured to call onclick() inside of Javascript A.

pastedimage1574873603635v2.png

I also added Javascript B as a dependecy of Javascript A. 

But somehow, if I click on my button, I can't access the test() function.

Crash Report: 

CrashReport:
		FileName:/tools/Solution/home_solution.aspx
		LineNumber:0
		Function:signIn
		ErrorReport:
  1.0
   XMLHandler
   {4edd0170-86c6-4bdd-9a85-7a5575ba0248}
  
   test is not defined
   0
   0
   /tools/Solution/home_solution.aspx?etc=7100&sitemappath=Settings|Customizations|nav_solution&pagemode=iframe
   /tools/Solution/home_solution.aspx?etc=7100&sitemappath=Settings|Customizations|nav_solution&pagemode=iframe
   signIn
   
   $webresource:cr8e3_authJS
   
ReferenceError: test is not defined
    at signIn (:3:1)
    at Function.Mscrm.Utilities.executeJavascriptFunction (https://crm4.dynamics.com/_common/global.ashx?ver=-330508:6872:600137)
    at Mscrm.CommandHandler.$Cu_1 (https://crm4.dynamics.com/_static/_controls/ribbon/ribbon.js?ver=-330508:1:82816)
    at Mscrm.CommandHandler.$Ap_1 (https://crm4.dynamics.com/_static/_controls/ribbon/ribbon.js?ver=-330508:1:82156)
    at Mscrm.CommandHandler.handleCommand (https://crm4.dynamics.com/_static/_controls/ribbon/ribbon.js?ver=-330508:1:77067)
    at Mscrm.CommandBarData.executeCommand (https:/crm4.dynamics.com/_static/_controls/ribbon/ribbon.js?ver=-330508:1:146512)
    at Mscrm.ButtonControl.executeCommand (https://crm4.dynamics.com/_static/_controls/ribbon/ribbon.js?ver=-330508:1:60031)
    at Mscrm.ButtonControl.click (https://crm4.dynamics.com/_static/_controls/ribbon/ribbon.js?ver=-330508:1:56116)
    at Mscrm.CommandBar.onClickHandler (https://crm4.dynamics.com/_static/_controls/ribbon/ribbon.js?ver=-330508:1:22257)
    at HTMLAnchorElement.cd (https://r1.res.office365.com/o365/versionless/shellcoreming2am_35b8ea41.js:58:18)
 

I have the same question (0)
  • Suggested answer
    gdas Profile Picture
    50,091 Moderator on at

    I can see the error says test is not defined in the web resource. Are those function you wrote in same webresource?

    If I am not wrong there might be some issue with the file which you referenced in ribbon workbench.

    Apart from above two functions ,is there any other code you wrote in the web resource? Check the file carefully , better to put all the code in VS editor to find any syntax errir might be somewhere apart from those function in the Js file having issue.

    You can create new JS web resource with above function and then reference that file in ribbon workbench.

  • Community Member Profile Picture
    on at

    Found the issue. I had to add the referenced Javascript B in the Ribbon Workbench Command for Javascript A with Functionname "isNaN".

  • Verified answer
    DynamicsAlex Profile Picture
    25 on at

    You must somehow "load" JavascriptB in the ribbon for it to be recognized, the "dependencies" thing I believe is meant for forms.

    Simply add another JavascriptFunction to the CommandDefinition *before* invokign test();  this new command should point to JavascriptB. As a function, you can use isNaN with no parameters.

    You'll end up with a CommandDefinition looking like this:

    > WebResource: JavascriptB    Function: isNaN

    > WebResource: JavascriptA    Function: test

  • Community Member Profile Picture
    on at

    Discovered this just 3 minutes before you ;) But thank though!

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Meet the Microsoft Dynamics 365 Contact Center Champions

We are thrilled to have these Champions in our Community!

Congratulations to the March Top 10 Community Leaders

These are the community rock stars!

Leaderboard > Customer experience | Sales, Customer Insights, CRM

#1
11manish Profile Picture

11manish 159

#2
ManoVerse Profile Picture

ManoVerse 138 Super User 2026 Season 1

#3
Jimmy Passeti Profile Picture

Jimmy Passeti 59 Most Valuable Professional

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans