Skip to main content
added 101 characters in body
Source Link
Pranay Jaiswal
  • 36.4k
  • 17
  • 79
  • 138

I have a way to do that, not sure if its the best.

Whenever you open the component in appbuilder, the window.location.href contains flexipageEditor/surface.app? . You can use that to your advantage.

<aura:component implements="force:appHostable,flexipage:availableForAllPageTypes,flexipage:availableForRecordHome,force:hasRecordId,forceCommunity:availableForAllPageTypes,force:lightningQuickAction" access="global" >
        
    
    <aura:handler name="init" value="{!this}" action="{!c.doInit}"/>
    <aura:attribute name="isAppBuilder" type="String" default="false"></aura:attribute>
    
    
    <aura:if isTrue="{!v.isAppBuilder}">
        My Component in App Builder
    </aura:if>

</aura:component>

JS:

({
    
    doInit : function(component, event, helper){
        if(window.location.href.includes('flexipageEditor/surface.app?') ){
            console.log('In App Builder');
            component.set("v.isAppBuilder" , true);
        }else{
             console.log('Not App Builder');   
        } 
    }
})

So here your isTrue block will only show if your app is viewed in app builder.

The only drawback is when SF changes their URL format for app builder, then this logic wont work.

I have a way to do that, not sure if its the best.

Whenever you open the component in appbuilder, the window.location.href contains flexipageEditor/surface.app? . You can use that to your advantage.

<aura:component implements="force:appHostable,flexipage:availableForAllPageTypes,flexipage:availableForRecordHome,force:hasRecordId,forceCommunity:availableForAllPageTypes,force:lightningQuickAction" access="global" >
        
    
    <aura:handler name="init" value="{!this}" action="{!c.doInit}"/>
    <aura:attribute name="isAppBuilder" type="String" default="false"></aura:attribute>
    
    
    <aura:if isTrue="{!v.isAppBuilder}">
        My Component in App Builder
    </aura:if>

</aura:component>

JS:

({
    
    doInit : function(component, event, helper){
        if(window.location.href.includes('flexipageEditor/surface.app?') ){
            console.log('In App Builder');
            component.set("v.isAppBuilder" , true);
        }else{
             console.log('Not App Builder');   
        } 
    }
})

So here your isTrue block will only show if your app is viewed in app builder.

I have a way to do that, not sure if its the best.

Whenever you open the component in appbuilder, the window.location.href contains flexipageEditor/surface.app? . You can use that to your advantage.

<aura:component implements="force:appHostable,flexipage:availableForAllPageTypes,flexipage:availableForRecordHome,force:hasRecordId,forceCommunity:availableForAllPageTypes,force:lightningQuickAction" access="global" >
        
    
    <aura:handler name="init" value="{!this}" action="{!c.doInit}"/>
    <aura:attribute name="isAppBuilder" type="String" default="false"></aura:attribute>
    
    
    <aura:if isTrue="{!v.isAppBuilder}">
        My Component in App Builder
    </aura:if>

</aura:component>

JS:

({
    
    doInit : function(component, event, helper){
        if(window.location.href.includes('flexipageEditor/surface.app?') ){
            console.log('In App Builder');
            component.set("v.isAppBuilder" , true);
        }else{
             console.log('Not App Builder');   
        } 
    }
})

So here your isTrue block will only show if your app is viewed in app builder.

The only drawback is when SF changes their URL format for app builder, then this logic wont work.

Source Link
Pranay Jaiswal
  • 36.4k
  • 17
  • 79
  • 138

I have a way to do that, not sure if its the best.

Whenever you open the component in appbuilder, the window.location.href contains flexipageEditor/surface.app? . You can use that to your advantage.

<aura:component implements="force:appHostable,flexipage:availableForAllPageTypes,flexipage:availableForRecordHome,force:hasRecordId,forceCommunity:availableForAllPageTypes,force:lightningQuickAction" access="global" >
        
    
    <aura:handler name="init" value="{!this}" action="{!c.doInit}"/>
    <aura:attribute name="isAppBuilder" type="String" default="false"></aura:attribute>
    
    
    <aura:if isTrue="{!v.isAppBuilder}">
        My Component in App Builder
    </aura:if>

</aura:component>

JS:

({
    
    doInit : function(component, event, helper){
        if(window.location.href.includes('flexipageEditor/surface.app?') ){
            console.log('In App Builder');
            component.set("v.isAppBuilder" , true);
        }else{
             console.log('Not App Builder');   
        } 
    }
})

So here your isTrue block will only show if your app is viewed in app builder.