0

I have a lightning component, which is added to the Account lightning page. lightning component opens a popup. This Popup opens on some conditions.

If I open 4 account records in different tabs in the console, popup is appearing in all 4 console tabs. What I want is to open this in one tab.

Lightning Component:

<aura:component controller="CustomController" implements="flexipage:availableForRecordHome,force:hasRecordId" access="global" >


    
<aura:attribute name="isOpen" type="boolean" default="false"/>
        <lightning:messageChannel type="purecloud__ClientEvent__c" aura:id="clientEventMessageChannel" onMessage="{!c.onClientEvent}" scope="APPLICATION"/>
        
        <div>
          
        <aura:if isTrue="{!v.isOpen}">
            <!--###### MODAL BOX Start######--> 
            <section role="dialog" tabindex="-1" aria-labelledby="modal-heading-01" aria-modal="true" aria-describedby="modal-content-id-1" class="slds-modal slds-fade-in-open">
                <div class="slds-modal__container">
                    <!-- ###### MODAL BOX HEADER Start ######-->
                    
                    <!--###### MODAL BOX FOOTER Part Start ######-->
                    <footer class="slds-modal__footer">
                        
                        <lightning:button variant="brand" 
                                          label="Save"
                                          title="Save"
                                          onclick="{! c.saveClose }"/>
                    </footer>
                </div>
            </section>
           
        </aura:if>
    </div>
</aura:component> 

Controller:

var action1 = component.get("c.getTaskRecords");
                action1.setParams({
                    interactionIds : eventIdData
                });
                action1.setCallback(this, function(response) {
                    var state = response.getState();
                    if (state === "SUCCESS") {
                        var list = response.getReturnValue();
                        console.log('>>> list... '+JSON.stringify(list))
                        component.set("v.taskid",list.Id);
                        component.set("v.segmentValue",list.Segment__c);
                        component.set("v.activityTypeValue",list.Activity_Type__c);
                        let recId = component.get("v.recordId");
                        console.log('>>> recId... '+recId);
                        if(list.Id == recId || list.WhatId == recId){
                            console.log('>>> If Condition is true... ');
                            component.set("v.isOpen",true);
                        }
                    }else{
                        console.log('>>> state in task method... '+state);
                    }
                })
                $A.enqueueAction(action1);

In my console log, I can see only one If Condition is true, which is setting isOpen to true, to open popup. But this component is opening popup in all 4 tabs.

How can I resolve this issue?

1 Answer 1

1

When using console tabs, you have to be aware of cross tab issue. The above code does not show from where the above code is getting called.

But seeing Application event I believe this might be getting triggered inside onClientEvent, that is why all four tabs might be listening to the event and opening respective modals.

So you can need to get the enclosedtabId using workspaceapi and pass tabid along with the message of the event. So that you can do a getEnclosedTabId in this onClientEvent and check if the tabId from the event is equal to the enclosedtabId. Then only run component.get("c.getTaskRecords");.

NOTE : If the action is not triggered from Application event listener, then if you can explain from where the action is getting triggered then will be able to help you better, as I have extensively worked on console tab cross tab issues.

9
  • This event is getting fired from the genesys cti dialer, basically whenever a call gets disconnected an event gets fired which is handled by this component Dec 6, 2020 at 10:24
  • So i believe this cti dialer is in utility bar? If yes ,then, instead of keeping the component on account page, keep the component in utility bar so that it only has one instance. And your modal will popup only once. Dec 6, 2020 at 14:10
  • Yes, it's in utility bar. My requirement is to show a popup on the screen, whenever call gets disconnected. for that I have added it in account page. Now if user opens four different accounts, the popup opens in all four Dec 6, 2020 at 14:12
  • You can add a component on utility bar itself to open the modal. Dec 6, 2020 at 14:13
  • But can I force user to select values in Utiltiy Bar? Dec 6, 2020 at 14:14

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .