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)

WebResource in CustomScriptsFrame not available on certain Entity Forms

(0) ShareShare
ReportReport
Posted on by

I have a custom workflow action defined by a plugin being triggered by a JavaScript Function.    *This works correctly.*

Using the Ribbon Workbench I defined a new button and a command to call this Javascript function.   *This works correctly.*

I have two forms on the Entity:

I have a legacy form from 2011 called "Information."   On this form the custom button works every time, it calls the Javascript and triggers the Workflow Action.

I have a new form that was built after upgrading to 2015 in order to use the Process Workflows.    On this form the custom button rarely works.  It appears that my custom Javascript function is not in scope when attempting to call it from the Ribbon.    Using the Development Tools from the browser, I sometimes can find the WebResource under the 'customscriptsframe' and sometimes cannot.

If I put a break-point in my Javascript and call my function from the console, it sometimes works, and sometimes gives me the error that there's no such function, even though I'm looking directly at it in the browser resources.

I think a lot of this is tied to how the contentframes and customscriptframes are generated, as sometimes I have multiple customscriptframes and sometimes I only have one.   Sometimes the WebResources folder is missing and my Javascript isn't even there, (although it's referenced in the Events/Scripts section of the Form designer.)

*This post is locked for comments

I have the same question (0)
  • Tomas Prokop Profile Picture
    590 on at

    Hi Cody, I have noticed in the past that ribbon script references are loaded dynamically when you click on the button that has command with such reference. Does you script has another dependencies?

  • Suggested answer
    Arun Vinoth Profile Picture
    11,615 Moderator on at

    From CRM 2013 onwards script loading enhanced a lot for performance tuning.

    Please read this post thoroughly.

    community.dynamics.com/.../crm-2013-script-loading-deep-dive

    Copied content from above link:

    Command Action scripts are loaded when the button is clicked and not when the page is loaded (unless they are used by the form or enable rules in which they are already loaded).

    Scripts loaded by Command Actions will appear as dynamic 'script block' and not a named URL in the IE F12 debugger.

  • Verified answer
    Community Member Profile Picture
    on at

    Thanks for that information.  It looked very promising.

    I turned on some 'Enable' rules for my button.  I verified they were working (the button comes and goes based on the state of my Entity form) However it doesn't seem to have done much to change the issue.   

    Even though it didn't fix the problem it did get me down the road of watching the resources load, (in the Network view of the Browser developer tools.)    Watching the difference between the working form and the non-working form, I found out there was a required sub-library that wasn't getting loaded.    The 'random' times when the button would work, it seems that library was getting loaded by some other means and was therefore available.

    I found on the working form this sub-library was expressly included, but on the broken form it wasn't.   Adding the required sub-library using the Form Properties made this work.    (Since there was never any error message...even in the Event Viewer and trace files...this was hard to track down.

  • Arun Vinoth Profile Picture
    11,615 Moderator on at

    Glad to hear it helped you to diagnose the root cause of the issue. Mark it as answer to close the thread & help other community members.

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