You need to sign in to do that
Don't have an account?
hitz
FIeld Set Image FIeld Issue
Hi, Experts
I have Created one Formula (Text) field which display images according to risk [red, green, yellow]. it works good in page layout means display image according to value but problem with field set.
i have created field set which contains that Formula (Text) field and some other fields set.
now i have created one VF page which display value in field set using below code
<apex:pageBlockSection columns="2"> <apex:repeat value="{!$ObjectType.myObj__c.FieldSets.General_Detail}" var="mo"> <apex:outputField value="{!mobjId[mo]}"/> </apex:repeat> </apex:pageBlockSection>
it displays other fields records good but it will not display image [it diaplays image path like <img src="green.gif" alt="abc"/>]
Hmm. Maybe contains throws an error when it doesn't like the type - I've also tried with number, text and currency and while the output isn't what I'm looking for I don't get an error.
However, its worth checking the type of field. I've revised my code below to check the type of field before looking for the value <img. Depending on how the boolean logic is implemented in Visualforce, this may need to be split out into seperate conditions, but try this to begin with:
All Answers
Yeah, unfortunately as the type of your field is a String, Salesforce renders it as-is.
I've used the following technique to work around this - its not elegant but does the trick. If the field containts the text '<img', I render it out as a label plus the unescaped HTML, otherwise I render it as a regular field:
Hi, bob
Thanks for quick reply,
but i have still problem it will show me an internal server error
How odd - mine displays the field as expected.
Can you post your revised code?
Hi, bob
my field set contains number,text, currency and image [formula [text] to..........
<apex:repeat value="{!$ObjectType.myObj__c.FieldSets.General_Detail}" var="mo">
<apex:outputPanel rendered="{!CONTAINS(mobjId[mo], '<img')}">
<apex:outputLabel value="{!$ObjectType.myObj__c.Fields[mo].label}"/>
<apex:outputText value="{!mobjId[mo]}" escape="false"/>
</apex:outputPanel>
<apex:outputField value="{!mobjId[mo]}" rendered="{!NOT(CONTAINS(mobjId[mo], '<img'))}"/>
</apex:repeat>
Hmm. Maybe contains throws an error when it doesn't like the type - I've also tried with number, text and currency and while the output isn't what I'm looking for I don't get an error.
However, its worth checking the type of field. I've revised my code below to check the type of field before looking for the value <img. Depending on how the boolean logic is implemented in Visualforce, this may need to be split out into seperate conditions, but try this to begin with:
Hi, bob
Thank you
i have also solved using below code
<apex:repeat value="{!$ObjectType.Account.FieldSets.Risk_Set}" var="ac">
<apex:outputPanel rendered="{!CONTAINS( $ObjectType.Account.Fields[ac].label, 'Risk')}">
<apex:outputLabel value="{!$ObjectType.Account.Fields[ac].label}"/>
<apex:outputText value="{!accId[ac]}" escape="false"/>
</apex:outputPanel>
<apex:outputField value="{!accId[ac]}" rendered="{!NOT(CONTAINS( $ObjectType.Account.Fields[ac].label, 'Risk'))}"/>
</apex:repeat>
it works but not formated display