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

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

Run JavaScript on all Navigation

(0) ShareShare
ReportReport
Posted on by

I have a requirement to render an external view within CRM an use the most page real estate possible. In order to achieve this I have a web resource which manipulates the DOM and then changes the source address of the iframe within #contentIFrame0 to the address of my view. The issue is that when I navigate to any other view, my DOM changes are still in effect. Namely, #crmTopBar, #formHeaderContainer and #formFooterContainer  are hidden and #crmContentPanel is still higher on the screen than it should be.

Script excerpt:

$(window.parent.parent.document.getElementById('crmTopBar')).hide();
$(window.parent.document.getElementById('formHeaderContainer')).hide();
$(window.parent.document.getElementById('formFootersContainer')).hide();
$(window.parent.parent.document.getElementById('crmContentPanel')).css('top', '50px');
$(window.parent.document.getElementById('mainContainer')).css('left', 0).css('max-width', 'unset');
$(window.parent.document.getElementById('tdAreas')).css('height', $(window.parent).height());

Is there a global from change or navigation change event that I can modify and add script to which will revert my DOM changes when navigating away from my new UI?

Things that don't work:

targeting #contentFrame0 to render my new view: this seems to break navigation entirely

modifying the webResource which I use for navigating to other pages: since the other forms are already loaded, this script does not run again if I go back to a previously loaded screen

*This post is locked for comments

I have the same question (0)
  • Mir Hassan Ali Profile Picture
    1,720 on at
    RE: Run JavaScript on all Navigation

    Hi

    Instead of changing the CRM UI by manipulating DOM (which is unsupported), why not display the view in your web resource?

    Regards

    Mir

  • Suggested answer
    RaviKashyap Profile Picture
    55,410 Moderator on at
    RE: Run JavaScript on all Navigation

    Hi zFournier,

    This is unsupported which is why the things have stopped working. Even if you figure out the way to change the DOM, there is no guarantee that it will continue to work with the future release.

    There must be some supported way to achieve your requirement. You could open the external URL directly using sitemap.

    Hope this helps.

  • Community Member Profile Picture
    on at
    RE: Run JavaScript on all Navigation

    Thanks Mir,

    The requirement I have is to maintain the CRM masthead and context and render the new view below. I can use an html file as a web resource, but in the context of an account it renders in an iframe in the middle of the page, and the command bar and form headers and footers are present which the business says is not acceptable. Is there any way to render my view using the full page height instead of inside the iframe?

  • Community Member Profile Picture
    on at
    RE: Run JavaScript on all Navigation

    Thanks Ravi,

    If I open the external URL directly, is there 1) a way to pass accountId to the external URL (we are currently handling this with some JavaScript in a web resource file)  and 2) is there a way to render with the CRM masthead or will I lose that context?

  • Community Member Profile Picture
    on at
    RE: Run JavaScript on all Navigation

    Correct me if I'm wrong:

    A site map component does not have context (in my case, accountId)

    A navigation property can't be displayed without the other form elements (header, footer, top bar)

    If either of those two assumptions is bad I might still have a chance :)

  • RaviKashyap Profile Picture
    55,410 Moderator on at
    RE: Run JavaScript on all Navigation

    Hi Zachariah,

    Yes, the sitemap doesn't have the context of the record. To get the context you need to be on the record. With that said, I don't think it is possible to use sitemap to load your external page.

    It has to be inside the record as you may have already tried Iframe/ Web Resource but then this will add the form header & footer.

    I am not sure if this is feasible but you could try creating a external page (asp.net web page) and load it in sitemap. In this page, display all the accounts such that user selects the account followed by your current logic.

    Sorry I don't have exact answer for your questions :(.

  • Pieter H Profile Picture
    on at
    RE: Run JavaScript on all Navigation

    Hi Zachariah, did you find a good working solution which preferably is supported? I have here a similar requirement and looking for a solution. I did found out that the MS Unified Service Desk (USD) has a configurable option to hide the navigation or command bar... See the documention at: msdn.microsoft.com/.../dn864949.aspx

    Unfortunately for me unclear how it was implemented.

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…

Pallavi Phade – Community Spotlight

We are honored to recognize Pallavi Phade as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
Community Member Profile Picture

Community Member 2

#1
UllrSki Profile Picture

UllrSki 2

#3
SC-08081331-0 Profile Picture

SC-08081331-0 1

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans