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" /> 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)'
Cheers 😎
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" /> 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 😎
Thanks for this Useful article.
ReplyDeleteKeep Sharing your knowledge to help others.
Dynamics 365 customer portal