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
DmuleDmule 

Image Formulas based on 3 Separate Pick list Values

HI,

I have been asked to build a formula field that gives and image (Traffic Light) that shows the lowest rating from 3 separate pick lists, Account Management Status, BDM Status and Partner Status, all have RED, GREEN & YELLOW as pick list values. So is 2 out of 3 are green but one us Yellow then my Image field would show YELLOW or the lowest rating of the 3 Picklists.

Thank you

Best Answer chosen by Admin (Salesforce Developers) 
SporterSporter

See Below:

 

Tested using my own status values and it works

 

IF( ISPICKVAL( Account_Management_Status__c , "Red") || ISPICKVAL( Business_Development_Status__c , "Red") || ISPICKVAL( Partner_Management_Status__c, "Red") ,  IMAGE("/img/samples/light_red.gif", "Red") ,

IF( ISPICKVAL( Account_Management_Status__c, "Yellow") || ISPICKVAL( Business_Development_Status__c ,Yellow) || ISPICKVAL( Partner_Management_Status__c, "Yellow") , IMAGE("/img/samples/light_yellow.gif", "Yellow") ,

IF( ISPICKVAL( Account_Management_Status__c , "Green") || ISPICKVAL( Business_Development_Status__c ,Green) || ISPICKVAL( Partner_Management_Status__c, "Green") ,  IMAGE("/img/samples/light_green.gif", "Green"), null)))

 

 

All Answers

SporterSporter

This should do the job, obviously replacing the text values with whatever your image forumla is:

 

 

IF( ISPICKVAL(Status_1__c, "Red") || ISPICKVAL(Status_2__c, "Red") || ISPICKVAL(Status_3__c, "Red") , "Red", 
IF( ISPICKVAL(Status_1__c, "Yellow") || ISPICKVAL(Status_2__c, "Yellow") || ISPICKVAL(Status_3__c, "Yellow") , "Yellow",
IF( ISPICKVAL(Status_1__c, "Green") || ISPICKVAL(Status_2__c, "Green") || ISPICKVAL(Status_3__c, "Green") , "Green", null)))

 

 

DmuleDmule

Hey mate do you mean something like this

 

IF( ISPICKVAL( Account_Management_Status__c , "Red", "/img/samples/light_red.gif) || ISPICKVAL( Business_Development_Status__c ,Red), "/img/samples/light_red.gif),  ISPICKVAL( Partner_Management_Status__c, "Red", "/img/samples/light_red.gif, Red) ,Red)"


IF( ISPICKVAL( Account_Management_Status__c, "Yellow", "/img/samples/light_yellow.gif) || ISPICKVAL( Business_Development_Status__c ,Yellow), "/img/samples/light_yellow.gif),  ISPICKVAL( Partner_Management_Status__c, "Yellow", "/img/samples/light_yellow.gif, Yellow) ,Yellow), "


IF( ISPICKVAL( Account_Management_Status__c , "Green", "/img/samples/light_Green.gif) || ISPICKVAL( Business_Development_Status__c ,Green), "/img/samples/light_green.gif),  ISPICKVAL( Partner_Management_Status__c, "Green", "/img/samples/light_Green.gif, Green) ,Green), "

SporterSporter

Yes but your IF statements are currently incorrect for example the first one:

 

 

IF( ISPICKVAL( Account_Management_Status__c , "Red", "/img/samples/light_red.gif) || ISPICKVAL( Business_Development_Status__c ,Red), "/img/samples/light_red.gif),  ISPICKVAL( Partner_Management_Status__c, "Red", "/img/samples/light_red.gif, Red) ,Red)"

 

 

should be:

 

 

IF( ISPICKVAL( Account_Management_Status__c , "Red") || ISPICKVAL( Business_Development_Status__c , "Red") || ISPICKVAL( Partner_Management_Status__c, "Red"), /img/samples/light_red.gif ,

IF( ISPICKVAL( Account_Management_Status__c, "Yellow") || ISPICKVAL( Business_Development_Status__c ,Yellow) || ISPICKVAL( Partner_Management_Status__c, "Yellow"), /img/samples/light_yellow.gif,

IF( ISPICKVAL( Account_Management_Status__c , "Green") || ISPICKVAL( Business_Development_Status__c ,Green) || ISPICKVAL( Partner_Management_Status__c, "Green"), "/img/samples/light_Green.gif, null)))

 

The above should be correct but if you get any errors let me know as I have not fully awoken from the weekend yet.

 

 

DmuleDmule

Hope you are ready for another weekend, i finally was able to get back and try your formula, than you for that however it gives me text and not a traffic light image, and when I try to add IMAGE to the formula it gives me an error Error: Incorrect number of parameters for function IMAGE(). Expected 2, received 3, what am i missing?

SporterSporter

Can you give me your entire code your using, the picklist api names, the location of the image files (full url please) and I'll see what I can do with that.

DmuleDmule

The formula is as you had it API Names Included, and I do not have a URL for the image, I thought the formula field "img/samples/light_red.gif would give the image? 

 

IF( ISPICKVAL( Account_Management_Status__c , "Red") || ISPICKVAL( Business_Development_Status__c , "Red") || ISPICKVAL( Partner_Management_Status__c, "Red"), "/img/samples/light_red.gif" ,

IF( ISPICKVAL( Account_Management_Status__c, "Amber") || ISPICKVAL( Business_Development_Status__c ,"Yellow") || ISPICKVAL( Partner_Management_Status__c, "Yellow"), "/img/samples/light_yellow.gif",

IF( ISPICKVAL( Account_Management_Status__c , "Green") || ISPICKVAL( Business_Development_Status__c ,"Green") || ISPICKVAL( Partner_Management_Status__c, "Green"), "/img/samples/light_Green.gif", null)))

 

Thank you for your help

 

 

SporterSporter

See Below:

 

Tested using my own status values and it works

 

IF( ISPICKVAL( Account_Management_Status__c , "Red") || ISPICKVAL( Business_Development_Status__c , "Red") || ISPICKVAL( Partner_Management_Status__c, "Red") ,  IMAGE("/img/samples/light_red.gif", "Red") ,

IF( ISPICKVAL( Account_Management_Status__c, "Yellow") || ISPICKVAL( Business_Development_Status__c ,Yellow) || ISPICKVAL( Partner_Management_Status__c, "Yellow") , IMAGE("/img/samples/light_yellow.gif", "Yellow") ,

IF( ISPICKVAL( Account_Management_Status__c , "Green") || ISPICKVAL( Business_Development_Status__c ,Green) || ISPICKVAL( Partner_Management_Status__c, "Green") ,  IMAGE("/img/samples/light_green.gif", "Green"), null)))

 

 

This was selected as the best answer
DmuleDmule

Works a treat and thank you for all your help

forceoneforceone

Hi Sporter:

 

I have an issue which follows this one. I did define Color_green.gif with simiar code. The formula fields gest displayed perfectly in standard screen. However, when I tried to define a Visualforce, I get text values. FYI the code is here:

<apex:page standardController="Project__c" recordSetVar="projects">
<apex:pageBlock >
    <apex:form id="theForm">
        <apex:pageBlockTable value="{!projects}"
            var="prj">
            <apex:column value="{!prj.name}"/>
            <apex:column headerValue="Scope">
            <apex:outputField value="{!prj.Scope_Color__c}"/>
            </apex:column>    
        </apex:pageBlockTable>
    </apex:form>
</apex:pageBlock>
</apex:page>

SporterSporter

Sorry forceone, visualforce and apex is out of my area (for the moment) and I'd not be able to assist you here, try over on the VF/Apex board in this forum.