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
component- 
<lightning:icon iconName="utility:email" />

apex class condition-

  if (isEmail){
                ChannelType = 'Chat';
            }


NEED HELP!!!!

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

Thanks 
Ami PandaAmi Panda
sorry but cannot share you the entire component part.
 
sfdcMonkey.comsfdcMonkey.com
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> 
sfdcMonkey.comsfdcMonkey.com
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" >
<a>
<lightning:icon iconName="{!v.searchVal == 'chat' ? 'utility:chat' : 'utility:email'}" /></a>
</div>
</twd> 

Thanks let us know if it helps you 
http://sfdcMonkey.com
 
sfdcMonkey.comsfdcMonkey.com
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 
thanks 
Ami PandaAmi Panda
yes i tried this one piyush, but i am not getting the desired result.
Is there any other alternative for this?
sfdcMonkey.comsfdcMonkey.com
okay let's check it you can contact with me on my email id sfdcmonkey@gmail.com
Thanks 
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..
NEED HELP!!!!

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>
                                    </tr>
                                </thead>
                               
                                <tbody>
                                    <aura:iteration items="{!v.SearchAllQueueResult}" var="queue" indexVar="count">   
                                        <tr>
                                            <td scope="row" style="width: 200px;"><div class="slds-truncate" ><a><lightning:icon iconName="{!v.SearchQueueKeyword == 'chat'? 'utility:chat' : 'utility:email'}" /></a></div></td>
                                        </tr>
                                    </aura:iteration>
                                </tbody>
                               
                            </table>
 
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(){
            publicGroupId='';
            publicGroupName='';
            publicGroupCreated ='';
            QueueType = '';
        }
    }
    @AuraEnabled
    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');
            QueueInfoList.add(pubGrpinfo);
        }
        system.debug(QueueInfoList);
        Set<id> idQueue = new Set<id>();
        for(Group qid: lstOfGroup)
        {
            idQueue.add(qid.Id);
        }
        String ChannelType;
        List <QueueSObject> queuetype = [SELECT QueueId, SobjectType, Queue.name 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');
            system.debug(isEmail);
            if (isEmail){
                ChannelType = 'Chat';
            }
           
            system.debug('Type--->' +ChannelType);
        }
        system.debug(queuetype);
        return QueueInfoList;
    }