Dynamically change image on HTML widget

Christine24
Giga Expert

I'm using the HTML widget as a way to display different logos depending on which company is signed into our portal. The issue I'm trying to resolve is how to actually make this dynamic so that we can use one portal and display the appropriate logo.

Right now the HTML widget will only display my one logo and I have to change the code to display the other logo. I decided to clone the HTML widget and wanted to make an if statement. This is what I have so far but I don't know how to code in HTML and it's not working.

<div>
  <div ng-if="!c.options.html" class="panel panel-default">
    <div class="panel-body">
    <a class="navbar-brand navbar-brand-logo" ng-if=user.company == '084cc9e64f4f7700eb11eddf0210c795' "
<p style="text-align: center; margin-top: 50px; margin-bottom: -50px;"><img src="cfn.svg" /></p>
<a class="navbar-brand navbar-brand-logo" ng-if=user.company == 'bd2eb1851bd73700762f8596dc4bcbc7' "
<p style="text-align: center; margin-top: 50px; margin-bottom: -50px;"><img src="mml.svg" /></p>
    </div>
  </div>
  <div ng-if="c.options.html" ng-bind-html="c.html"></div>
</div>
1 ACCEPTED SOLUTION

Mike Patel
Tera Sage

try below

<div>
  <div class="panel-body">
    <img style="text-align:center; margin-top:50px; margin-bottom:-50px;" ng-if="data.companylogovalue == '084cc9e64f4f7700eb11eddf0210c795'" ng-src="cfn.svg">
    <img style="text-align:center; margin-top:50px; margin-bottom:-50px;" ng-if="data.companylogovalue == 'bd2eb1851bd73700762f8596dc4bcbc7'" ng-src="mml.svg">
  </div>
  <div ng-if="c.options.html" ng-bind-html="c.html"></div>
</div>

Server

data.companylogovalue=gs.getUser().getCompanyID().toString();

View solution in original post

34 REPLIES 34

Okay, the Hello is gone!!!!!!!!

Now it's still displaying both logos regardless of what company is logged in. Any ideas on why the If statement is not working?

Change this in Server Script and also check whether the sys_id in the HTML are correct or not.

 

var gr = new GlideRecord('sys_user');
gr.addQuery('sys_id',gs.getUserID());
gr.query();
if(gr.next()){
	data.companylogovalue = gr.company; 


}

Still same issue.

I double checked the sys_ids and they're both right.

So we have three companies that sign in, but I only want to use this portal for two of the companies, but could that be the issue? Just spit balling ideas.

yes I think so.

 

Check whats coming in the logs and see if it matches the sys id.

 

var gr = new GlideRecord('sys_user');
gr.addQuery('sys_id',gs.getUserID());
gr.query();
if(gr.next()){
gs.info(gr.company);
	data.companylogovalue = gr.company; 


}

I could be looking in the wrong spot but I checked the logs and I'm not seeing any issues