Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8273839
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T07:34:56+00:00 2026-06-08T07:34:56+00:00

I’m a developer but I haven’t touched salesforce before. I’ve been given this: <td

  • 0

I’m a developer but I haven’t touched salesforce before.

I’ve been given this:

<td class="textAlignRight">
<apex:outputPanel rendered="{!relatedTo.c2g__OwnerCompany__r.c2g__LogoURL__c<>''}"><img src="{!relatedTo.c2g__OwnerCompany__r.c2g__LogoURL__c}"/>
</apex:outputPanel>
</td>

and told that rather than putting in the logo of OwnerCompany, I should be putting in the logo of Parent, but if the LogoURL property of Parent is blank, I should put in the LogoURL of it’s parent, and so on, until I find a logo or there are no more parents, in which case I should put the OwnerCompany LogoURL in.

I’m having trouble googling the language that salesforce uses. Does anyone have any ideas how I can solve this? Some kind of function call to a method with a loop?

Edit:

Apparently it needs to do this:

Invoice > Account > LogoURL

Invoice > Account > ParentAccount > LogoURL

Invoice > Account > ParentAccount > ParentAccount > LogoURL

etc.

where Invoice is the relatedToType.

So I guess I need to check LogoURL, if it’s blank check ParentAccount, if that’s blank, check ParentAccount.ParentAccount, etc. and if the last one of those is blank, use

Invoice > OwnerCompany > LogoURL

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T07:34:57+00:00Added an answer on June 8, 2026 at 7:34 am

    I’ll take a stab at this…this code is assuming that the c2g__OwnerCompany__r field is pointing to an Account record, which in turn has its own c2g_OwnerCompany__r field pointing to a parent account (if it has one). VisualForce is not really built for this this type of recursion, and I think you’ll see why:

    <apex:variable var="parentLogo" value="{!relatedTo.c2g__OwnerCompany__r.c2g__LogoURL__c}" />
    <apex:variable var="parentLogo2" value="{!relatedTo.c2g__OwnerCompany__r.c2g__OwnerCompany__r.c2g__LogoURL__c}" />
    <apex:variable var="parentLogo3" value="{!relatedTo.c2g__OwnerCompany__r.c2g__OwnerCompany__r.c2g__OwnerCompany__r.c2g__LogoURL__c}" />
    <td class="textAlignRight">
        <apex:outputPanel rendered="{!parentLogo<>''}">
            <img src="{!parentLogo}"/>
        </apex:outputPanel>
        <apex:outputPanel rendered="{!AND(NOT(parentLogo<>''), parentLogo2<>'')}">
            <img src="{!parentLogo2}"/>
        </apex:outputPanel>
        <apex:outputPanel rendered="{!AND(NOT(parentLogo<>''), NOT(parentLogo2<>'') parentLogo3<>'')}">
            <img src="{!parentLogo3}"/>
        </apex:outputPanel>
    </td>
    

    I wouldn’t really recommend this approach, as it quickly makes a mess out of your VF page and also has a limit on how many levels down you can start at.

    A alternative solution would be to handle this in your controller class, where have much more control over the recursion. It’s worth noting that Salesforce imposes strict limits on the number of times you can hit the database in the context of a single call, so you’ll want to figure out a way to restrict the number of queries that this makes. I would probably only use this if you can guarantee that you only have a couple levels of parent accounts and that there are no circular references:

    public String getLogoUrl() {
        String logo;
        Account acc= [select Id, c2g__OwnerCompany__c, c2g__LogoURL__c from Account where Id = :relatedTo.c2g__OwnerCompany__c];
        // running SOQL queries inside of loops is most certainly NOT a Salesforce best practice
        while ( true ) {
            logo = acc.c2g__LogoURL__c;
            if ( acc.c2g__OwnerCompany__c != null )
                acc = [select Id, c2g__OwnerCompany__c, c2g__LogoURL__c from Account where Id = :acc.c2g__OwnerCompany__c];
            else
                break;
        }
        return logo;
    }
    

    This in turn simplifies your VF page to something similar to what you started out with. The logoUrl variable will automatically be populated when the page loads by a call to getLogoUrl in the controller:

    <td class="textAlignRight">
        <apex:outputPanel rendered="{!AND(NOT(ISNULL(logoUrl)), logoUrl<>'')}">
            <img src="{!logoUrl}"/>
        </apex:outputPanel>
    </td>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I want to count how many characters a certain string has in PHP, but
For some reason, after submitting a string like this Jack’s Spindle from a text
I have a jquery bug and I've been looking for hours now, I can't
this is what i have right now Drawing an RSS feed into the php,
I have this code to decode numeric html entities to the UTF8 equivalent character.
I have a French site that I want to parse, but am running into
I am doing a simple coin flipping experiment for class that involves flipping a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.