• Brian Rosenfelt
  • NEWBIE
  • 0 Points
  • Member since 2019


  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 4
    Questions
  • 5
    Replies
We currently are utilizing a lightning page using only standard lightning components.  We use TABS to display several tabs for users to navigate across.  One of those tabs has a custom visualforce page we developed.  When a user initiates and action from that VF page, the screen refreshes and takes the user back to the default tab as defined (instead of the tab they called the action from).

We are hoping to avoid building a custom tabset component, as the out of the box component makes it easy for our team to add/remove/modify components via drag and drop.

Is there any coding we can add to our VF page to bring the user back to the tab the started on?  As each tab does not have a unique URL, using a return URL string doesn't seem to be an option.

Was curious if getFocusedSubtabObjectId() would work in this use case, but not sure its intended to get an ID for a lightning tab.

Any additional thoughts would be appreciated.
I created a lightning component for CASE that will update the TAB NAME (in Saleforce Console) with different data elements.  Default TAB NAME would be the Case number.  Currently, the new component will make the TAB NAME "Loan Name - Case Number".  Instead, we'd like it to be "Loan Name - Record Type Name".  In order to accomplish that, I know we need to add a SOQL query to query the record type name.  I'm having a little trouble figuring out where to insert that SOQL query in my controller.  Any help would be appreciated.

LIghtning Component:
<aura:component implements="flexipage:availableForAllPageTypes,flexipage:availableForRecordHome,force:hasRecordId" access="global">
     
    <!--Attributes-->
    <aura:attribute name="caseFields" type="Case"/>
     
    <!--Component Start-->
     
    <!--Lightning Workspace API-->
    <lightning:workspaceAPI aura:id="workspace"/>
     
    <!--Lightning Force Data to get Account record-->
    <force:recordData aura:id="caseRecordData"
                      layoutType="FULL"
                      recordId="{!v.recordId}"
                      targetFields="{!v.caseFields}"
                      recordUpdated="{!c.handleRecordUpdate}"/>
    <!--Component End-->
</aura:component>

Controller:
({
    handleRecordUpdate: function(component, event, helper) {
       
        var caseFields = component.get("v.caseFields");
        var workspaceAPI = component.find("workspace");
        workspaceAPI.getFocusedTabInfo().then(function(response) {
            var focusedTabId = response.tabId;
            workspaceAPI.setTabLabel({
                tabId: focusedTabId,
                label: caseFields.E2E_LOAN_NAME__c + ' - ' + caseFields.CaseNumber
            });
        })
        
    }
})

I believe this is the query language that needs to be inserted into the controller:
 
List<Case> lstCase = [select Id, RecordTypeId, RecordType.Name from Case limit 10];

for(Case x : lstCase) {
    system.debug('Case - ' + x.Id + ' - ' + x.RecordTypeId + ' - ' + x.RecordType.Name);
}

User-added image
Looking for help on this error - I'm sure a small syntax issue in my code.  Thank you!
 
<aura:component implements="flexipage:availableForAllPageTypes,force:appHostable,flexipage:availableForRecordHome,force:hasRecordId" access="global" controller="ChangeCaseLabel">
    <aura:handler name="init" value="this" action="{!c.doInit}"/>
    <aura:handler event="force:refreshView" action="{!c.doInit}" />  
    <lightning:workspaceAPI aura:id="workspace" />
</aura:component>
 
({
   init : function(component, event, helper) {
        var action = component.get("c.getCaseOrigin");
        action.setParams({ caseId: component.get("v.recordId")});
        action.setCallback(this,$A.getCallback(function(response1)
         {
         var state = response1.getState();             
         if (state === "SUCCESS")  
         {
             var result= response1.getReturnValue();
         var workspaceAPI = component.find("workspace");
         workspaceAPI.getFocusedTabInfo().then(function(response) {
            var focusedTabId = response.tabId;
            workspaceAPI.setTabLabel({
                tabId: focusedTabId,
                label: result
            });
        })
        .catch(function(error) {
            console.log(error);
        });
         }
         }
        ));
        $A.enqueueAction(action);       
        
        
    }
})
 
({
	doInit : function(component, event, helper) {
		helper.init(component, event, helper);
	}
})
 
public with sharing class ChangeCaseLabel {
    public static ChangeCaseLabelService service = new ChangeCaseLabelService();
    @AuraEnabled 
    public static String getCaseOrigin(String caseId){
        return service.getCaseOrigin(caseId);
    }
    
    
}
 
public class ChangeCaseLabelService {
    
    public String getCaseOrigin(String caseId){
        Case c = [Select id ,CaseNumber , Origin from Case where Id = :caseId];
        return c.Origin+'-'+c.CaseNumber ; 
    }
}

 
I'm trying to build a formula on a child object that compares a value to the current record ID of the page being called.  I know I can retrieve the current page ID using APEX, but not sure if there is a function I can use in a formula field.

I'm trying to created a list filter so it compares an ID from the child record to the id of the page its being called from.

Any suggestions?
Looking for help on this error - I'm sure a small syntax issue in my code.  Thank you!
 
<aura:component implements="flexipage:availableForAllPageTypes,force:appHostable,flexipage:availableForRecordHome,force:hasRecordId" access="global" controller="ChangeCaseLabel">
    <aura:handler name="init" value="this" action="{!c.doInit}"/>
    <aura:handler event="force:refreshView" action="{!c.doInit}" />  
    <lightning:workspaceAPI aura:id="workspace" />
</aura:component>
 
({
   init : function(component, event, helper) {
        var action = component.get("c.getCaseOrigin");
        action.setParams({ caseId: component.get("v.recordId")});
        action.setCallback(this,$A.getCallback(function(response1)
         {
         var state = response1.getState();             
         if (state === "SUCCESS")  
         {
             var result= response1.getReturnValue();
         var workspaceAPI = component.find("workspace");
         workspaceAPI.getFocusedTabInfo().then(function(response) {
            var focusedTabId = response.tabId;
            workspaceAPI.setTabLabel({
                tabId: focusedTabId,
                label: result
            });
        })
        .catch(function(error) {
            console.log(error);
        });
         }
         }
        ));
        $A.enqueueAction(action);       
        
        
    }
})
 
({
	doInit : function(component, event, helper) {
		helper.init(component, event, helper);
	}
})
 
public with sharing class ChangeCaseLabel {
    public static ChangeCaseLabelService service = new ChangeCaseLabelService();
    @AuraEnabled 
    public static String getCaseOrigin(String caseId){
        return service.getCaseOrigin(caseId);
    }
    
    
}
 
public class ChangeCaseLabelService {
    
    public String getCaseOrigin(String caseId){
        Case c = [Select id ,CaseNumber , Origin from Case where Id = :caseId];
        return c.Origin+'-'+c.CaseNumber ; 
    }
}

 
I'm trying to build a formula on a child object that compares a value to the current record ID of the page being called.  I know I can retrieve the current page ID using APEX, but not sure if there is a function I can use in a formula field.

I'm trying to created a list filter so it compares an ID from the child record to the id of the page its being called from.

Any suggestions?