Wednesday 7 February 2018

Dynamically Change the Portal Logo based on Logged In User's Account

Hello Everyone,

There might be a requirement for your client to change the Portal Logo based on the different user's account.

For Example - If the Logged In User's Account is Twitter, He/she should be able to see the Twitter logo on the Portal, same for Chrome and Android Account's Users.

Here is the code, I have written for above example:

Before writing this code, I have already been uploaded the images in web files.



<p><strong><img alt="" id="logoId" style="width: 60px; height: 40px;" src="/Handshake_Emoji_Icon_ios10.png" />&nbsp;Arpit's Dynamics CRM Blog</strong></p><script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script><script>

  changeLogo();

  function changeLogo() {

    // get Logged In User's account name
    var loggedInuseraccount = '{{user.parentcustomerid.Name}}';

     // can get Logged In User's name, if you want to change logo based on user name
    var loggedInuseraccount = '{{user.fullname}}';


    if (loggedInuseraccount == 'Chrome') {

      $("#logoId").attr("src", "/chrome");

    }

    if (loggedInuseraccount == 'Twitter') {

      $("#logoId").attr("src", "/twitter");

    }
    if (loggedInuseraccount == 'Android') {

      $("#logoId").attr("src", "/android");

    }

  }
</script>


Paste this code inside 'Navbar Left' Content Snippet.

Navigate to- Portals > Open 'Navbar Left' Content Snippet > Paste above code under 'Value(HTML)'










Demo :

For Android Account's Portal Users





For Chrome Account's Portal Users





For Twitter Account's Portal Users









Cheers 😎

2 comments:

  1. Thanks for this Useful article.

    Keep Sharing your knowledge to help others.

    Dynamics 365 customer portal

    ReplyDelete
  2. This is helpful, nonetheless it can be crucial so that you can check out the following website: drone photography logo

    ReplyDelete

Blogger Widgets