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)

Using Custom Javascript On The Portal

(0) ShareShare
ReportReport
Posted on by

Hi.

I have a requirement to hide certain things from the Sign In page.

Now as this is not defined as a web template I need to do this via javascript.

My understanding is that I should be able to create a new Web File record, attach my javascript file to this as a note and then each page on the site should contain this script file.

This is exactly what I did previously to get a custom css file available on all pages of the site.

However, this does not seem to work for javascript files. I have restarted the portal several times but the javascript is never present on any of the site pages.

Is there something else I need to do to make my javascript file take effect?

*This post is locked for comments

I have the same question (0)
  • sbelzile Profile Picture
    on at

    Last time I tried, I could not make it work either.

    After some research, I found this: crmideas.dynamics.com/.../ID0000085.

    I guess it is not yet supported.

  • Craig P. Fleming Profile Picture
    950 on at

    This can be achieved but not using the same technique as with css files. You need to create a webfile for the desired js, then add a standard script tag for example <script src="/myscript.js"></script> to a Content Snippet with the name "Tracking Code" (this may or may not exist). This snippet will be included in any page that uses the default master page for the site right before the closing body tag.  I should add that in theory you could add the script tag to any content snippet that exists on the signin page to isolate it, as it is simply an html tag. You just need to aware that a user may inadvertently remove it if they use the use the front side editing as it will not be visible.

  • Suggested answer
    Nithya Gopinath Profile Picture
    17,078 on at

    Hi jimbob,

    The steps for adding the custom JavaScript to portal is explained in detail in the portal development guide below. Please go through the link.

    www.aayushsingh.in/.../adxstudio-portal-development-guide.html

  • Craig P. Fleming Profile Picture
    950 on at

    Nithya, your documentation only applies to v7 self hosted portals. For v8 and beyond the web file technique is currently the only supported option.

  • Community Member Profile Picture
    on at

    Hi, I tried this but didn't seem to work.. I might have miss something - so I did:

    create a web file as you normally would with CSS and maybe call it myscript.js but not upload a js file?

    Create a content snippet as above and put the script tag in when do you put your actual script ? when I tried this it said '404 not found .../myscript.js..'

    Any suggestion ?

  • Birgit RD Profile Picture
    2 on at

    Did anyone succeeded in adding a custom js file?

    I'm requested by Microsoft to do so for another issue, but facing same issue as pdiaz1000.

  • Suggested answer
    RamKumarb Profile Picture
    828 on at

    Hi jimbob,

               i don't think you can make changes in SIGN-IN page using custom javascript,  but you can hide certain things in signup page by modifying the CSS, like hiding the external login  button.  Removing the registration options for a new user etc.

    and yes you can add your custom javascript to a portal web-page and perform some operation .

  • Craig P. Fleming Profile Picture
    950 on at

    pdiax1000, Just to be clear when you say "call it myscript.js but not upload a js file" if you mean you did not upload a file then this would be the expected result.  You need to upload the js file.

  • Craig P. Fleming Profile Picture
    950 on at

    Unfortunately the signin page is a tricky one to deal with because of the nature of how that page is implemented. It's possible that the css could influence other aspects of the site unintended but that is not to say it's not possible. In js you can detect the url and control the logic a bit more carefully and make changes accordingly.  

  • Birgit RD Profile Picture
    2 on at

    Craig,

    We are not able to upload a file with extension .js

    We tried to do it via de portal (New child). In that case, no error is displayed, but when inspecting the web file entry in CRM, no file in the notes section is added.

    Wen we try to add it directly in CRM, we get the error message "Invalid file type".

    As we don't succeed in uploading a javascript file, we have copied a couple of lines of javascript on every single web page. Not the most pleasant work, but at least we could work around the issue.

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