function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Ami PandaAmi Panda 

can we change a lightning icon present in a lightning component via an apex class?

on typing chat in the search box, this icon under channel should change to chat bubble.
Ami PandaAmi Panda
<lightning:icon iconName="utility:email" />

apex class condition-

  if (isEmail){
                ChannelType = 'Chat';

Hi Amrita yes it's possible but can you please share your lightning component code so i can check 

Ami PandaAmi Panda
sorry but cannot share you the entire component part.
don't share entire code. just a sample code of data table and button, and on clicking on chat button do we need to update the icon ? 
Ami PandaAmi Panda
There is no button.. its like there is a search box above , and if we search "chat" den this icon should be changed to a chat icon.

 <td scope="row" style="width: 200px;"><div class="slds-truncate" ><a><lightning:icon iconName="utility:email" /></a></div></td>
okay then try somthing like this, don't need of apex here 
<aura:attribute name="searchVal" type="string"/>

<lightning:input name="search" label="search box" value="{!v.searchVal}"/>

<td scope="row" style="width: 200px;">
   <div class="slds-truncate" >
<lightning:icon iconName="{!v.searchVal == 'chat' ? 'utility:chat' : 'utility:email'}" /></a>

Thanks let us know if it helps you
OR :
<td scope="row" style="width: 200px;"><div class="slds-truncate" ><a><lightning:icon iconName="{!yourVarName.ChannelType == 'Chat'? 'utility:chat' : 'utility:email'}" /></a></div></td>

update yourVarName  with your aura:iteration variable name 
Ami PandaAmi Panda
yes i tried this one piyush, but i am not getting the desired result.
Is there any other alternative for this?
okay let's check it you can contact with me on my email id
Ami PandaAmi Panda
can we do like displaying chat bubble for chat queues and remaining let it be email......the logic for fetching chat queue is there in the apex class..

Component –
<table class="slds-table slds-table_bordered slds-table--header-fixed">
                                <thead >
                                    <tr class="slds-text-title_caps" >
                                        <th scope="col"><div class="slds-truncate slds-cell-fixed" style="width: 275px;padding-top: 10px;" title="Channel">Channel</div></th>
                                    <aura:iteration items="{!v.SearchAllQueueResult}" var="queue" indexVar="count">   
                                            <td scope="row" style="width: 200px;"><div class="slds-truncate" ><a><lightning:icon iconName="{!v.SearchQueueKeyword == 'chat'? 'utility:chat' : 'utility:email'}" /></a></div></td>
Apex class-
  public class QueueInfo{
        @AuraEnabled public string publicGroupId;
        @AuraEnabled public string publicGroupName;
        @AuraEnabled public string QueueType;
        @AuraEnabled public String publicGroupCreated;
        @AuraEnabled public Date CreatedDate;
        public QueueInfo(){
            publicGroupCreated ='';
            QueueType = '';
    public static List <QueueInfo> fetchQueue () {
        List <Group> returnList = new List <Group> ();
        List <Group> lstOfGroup = [select Id,Name,CreatedDate from Group where type='Queue' LIMIT 500]; 
        //List <QueueSobject> lstOfGroup = [SELECT Queue.Name,QueueId,SobjectType FROM QueueSobject WHERE Queue.Name like '%AMERICAS%' LIMIT 500];                                                 
        list <QueueInfo> QueueInfoList = new List<QueueInfo>();
        list <QueueSobject> lstqueueid;
        QueueInfo pubGrpinfo;
        for (Group u: lstOfGroup) {
            pubGrpinfo = new QueueInfo();
            pubGrpinfo.publicGroupId = u.Id;
            pubGrpinfo.publicgroupName = u.Name;
            //pubGrpinfo.QueueType = u.SobjectType;
            pubGrpinfo.publicGroupCreated = u.CreatedDate.format('dd-MMM-YYYY');
        Set<id> idQueue = new Set<id>();
        for(Group qid: lstOfGroup)
        String ChannelType;
        List <QueueSObject> queuetype = [SELECT QueueId, SobjectType, FROM QueueSobject where SobjectType='LiveAgentSession' and QueueId in: idQueue LIMIT 500 ];
        for (QueueSObject qo: queuetype ){
            String Channel = qo.SobjectType;
            system.debug('Channel---->' + Channel);
            Boolean isEmail=Channel.contains('LiveAgentSession');
            if (isEmail){
                ChannelType = 'Chat';
            system.debug('Type--->' +ChannelType);
        return QueueInfoList;