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
Venkata Shiva Koushik RachapudiVenkata Shiva Koushik Rachapudi 

How to Query Account Logo.

Hello Everyone, we have enabled account logo in salesforce org. after the Account Logo was enabled, salesforce provided us with few images for known accounts, and when requested for existing small name customers we were told that not all accounts have their logo's associated in salesforce database, so we would require to manually upload the file on our end. so i wanted to know how to associate a logo with an account and how to query it from data migrator tool?
Deepali KulshresthaDeepali Kulshrestha
Hi Venkata Shiva Koushik Rachapudi,
Greetings to you!
Please used these code to get the icon for  All sObject.


Controller
==========
 
public class newobjectdetail {

@AuraEnabled
    public static String getIconName(String sObjectName1){
        String u;
        List<Schema.DescribeTabSetResult> tabSetDesc = Schema.describeTabs();
        List<Schema.DescribeTabResult> tabDesc = new List<Schema.DescribeTabResult>();
        List<Schema.DescribeIconResult> iconDesc = new List<Schema.DescribeIconResult>();

        for(Schema.DescribeTabSetResult tsr : tabSetDesc) { tabDesc.addAll(tsr.getTabs()); }

        for(Schema.DescribeTabResult tr : tabDesc) {
            system.debug('getSobjectName...'+tr.getSobjectName());
            if( sObjectName1 == tr.getSobjectName() ) {
                if( tr.isCustom() == true ) {
                    iconDesc.addAll(tr.getIcons());
                } else {
                    u = 'standard:' + sObjectName1.toLowerCase();
                }
            }
        }
        
            System.debug('iconDesc..'+iconDesc);
        for (Schema.DescribeIconResult ir : iconDesc) {
            system.debug('getContentType...'+ir.getContentType());
            if (ir.getContentType() == 'image/svg+xml'){
                u = 'custom:' + ir.getUrl().substringBetween('custom/','.svg').substringBefore('_');
                break;
            }
        }
        System.debug('uu....'+u);
        return u;
    }
    @AuraEnabled
    public static List<String> getObjectlist()
    { list<String> objlist=new list<String>();
      List<Schema.DescribeTabSetResult> tabSetDesc = Schema.describeTabs();
      List<Schema.DescribeTabResult> tabDesc = new List<Schema.DescribeTabResult>();
         for(Schema.DescribeTabSetResult tsr : tabSetDesc) { tabDesc.addAll(tsr.getTabs()); }
      for(Schema.DescribeTabResult tr : tabDesc) 
     {
         objlist.add(tr.getSobjectName());
     }
     
     System.debug('.........'+objlist);
    return objlist;
        
    }
    
}



Aura component
==============

<aura:component controller="newobjectdetail" implements="flexiPage:availableForAllPageTypes,force:hasSObjectName">
    <aura:handler name="init" value="{!this}" action="{!c.doInit}"/>
    
    <aura:attribute name="iconName" type="String" />
    <aura:attribute name="objName" type="String[]" />
    <div class="slds-align_absolute-center" style="height:10rem">
        <lightning:select name="objectn" aura:id="objectn" onchange="{!c.onChange}">
             <option value=""> --None--</option>
        <aura:iteration items="{!v.objName}" var="obj" >
            <option value="{!obj}"> {!obj}</option>
        </aura:iteration>
    </lightning:select>
    
    
    
    <lightning:icon iconName="{!v.iconName}" size="large" alternativeText="Indicates approval"/>
    </div>
</aura:component>


Helper
========
({
    doInit : function(component, event, helper) {
      
         var action = component.get("c.getObjectlist");

        action.setCallback(this,function(res){
            if(res.getState()==="SUCCESS"){
                console.log('----->');
                console.log(res.getReturnValue());
                console.log("Account saved Successfully");
                component.set('v.objName',res.getReturnValue());
               // alert("new account inserted");
            }
        })
        $A.enqueueAction(action);
    },

    
      onChange: function(component, event, helper){
       
       console.log(component.find("objectn").get("v.value"));
          
           var action = component.get("c.getIconName");
        action.setParams({ "sObjectName1" : component.find("objectn").get("v.value")});
        action.setCallback(this, function(response) {
           component.set("v.iconName", response.getReturnValue() );
        });
        $A.enqueueAction(action);
          
    },
})


I hope you find the above solution helpful. If it does, please mark as Best Answer to help others too.

Thanks and Regards,
Deepali Kulshrestha
www.kdeepali.com
Venkata Shiva Koushik RachapudiVenkata Shiva Koushik Rachapudi
@Deepali,
I tried to copy and use the current code, also i do not understand why the component itself is not showing up, is this going to be a lightning App? am i missing something in here to run this component? since i am new to lightning could you please explain to me how to use this code?
sunil Pal 13sunil Pal 13
Hi @Venkata

Please let me know if you got any workaround. The above code give us the standard account logo not the one which I used when Account setting enable.