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)

How to load JavaScript used in JS function called from the Ribbon ?

(0) ShareShare
ReportReport
Posted on by 2,541

Hello,

I have a requirement for my company : Hide the "Export to Excel Online" button based on the Security role for the Ribbon : Mscrm.Homepage.Grid.list.MainTab.
I know that I can't manage this directly via the RibbonWorkbench.

So I decided to go for a custom function which return a true or false if the user has the specific role.

So far, no problem.
But in my custom function I use the js library : XrmServiceToolkit.

So when I debug my function, I get a nice : "XrmServiceToolkit is not defined". In a certain way it makes sense, since on this view, I can't force the loading of JS files like we can do on a form.

I found this article : https://rajeevpentyala.com/2012/05/23/loading-dependent-jscript-libraries-in-ribbon-buttons-execution-crm-2011/ but it is the same result for me.

If anyone has a solution.

Thanks a lot,

Clément 

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    Mahadeo Matre Profile Picture
    17,021 on at

    Hi,

    Make sure function name used for XrmServiceToolkit library is  "isNaN" , in proper case,

    Also try clearing your browser cache, so that script will be loaded.

  • Clem Profile Picture
    2,541 on at

    2016_2D00_09_2D00_23_5F00_17_2D00_19_2D00_56_5F00_XrmToolBox.png

    As you can see here, it's what I did according to the blog article I posted in the ticket.
    But I always receive the "XrmServiceToolkit is undefined" also with a clean browser.

  • Suggested answer
    JohnAnonymous Profile Picture
    5,241 on at

    I'm guessing that your script isn't loaded because of the way turbo forms work. It only loads the JavaScript when te function is called. At least for form JavaScript.

    Might want to have a look at something like this:

    stackoverflow.com/.../how-to-include-a-javascript-file-in-another-javascript-file

    Or, the most simple solution, merge the two files. It's not ideal, but it's certain to work.

  • Clem Profile Picture
    2,541 on at

    Hello martijn,

    I disabled the new Turbo form rendering so this shouldn't be an issue.

    I thought about the dynamic load of the WebResource, but putting in hardcode the path to the file is a bit ugly solution no ? and even with this solution, I get a 500 http error.

  • Vineet  Mehra Profile Picture
    75 on at

    Hi Clement,

    I am also facing the same issue in Dynamics 365. Were you able to resolve it ?

  • Clem Profile Picture
    2,541 on at

    Hi Winnie,

    I didn't find a wordaround yet. But for sure, i will update this ticket if i find one !

  • Suggested answer
    Luke Sartain Profile Picture
    1,266 on at

    Hi Clément 

    Forgive me if I am oversimplifying it but as a workaround you can always turn off Excel to Excel in the security role configuration.

    exporttoexcel.png

    Luke

  • Clem Profile Picture
    2,541 on at

    Hi Luke,

    Thanks for your input.

    Unfortunately, I need the default export to excel (which is available for everyone with a specific role) but i need to manage the availability of the export to excel online for users based on the role.

    Clément

  • Vineet  Mehra Profile Picture
    75 on at

    Hey Clement,

    I got the solution in my forum question:

    https://community.dynamics.com/crm/f/117/p/234612/642795#642795 

    Let me know, if you have any question, maybe I will be able to help you.

  • Verified answer
    sam hajjar Profile Picture
    25 on at

    Hi from 2019,

    I recently encountered the same issue, loading nested web resources in the view context.

    Solution: In ribbon workbench add javascript actions calling 'isNaN' function for the nested library. The order counts though, these actions should be on top of the initial javascript command.

    Cheers

    Sam

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