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
I’ll take a stab at this…this code is assuming that the
c2g__OwnerCompany__rfield is pointing to an Account record, which in turn has its ownc2g_OwnerCompany__rfield 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: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:
This in turn simplifies your VF page to something similar to what you started out with. The
logoUrlvariable will automatically be populated when the page loads by a call togetLogoUrlin the controller: