-1

can I put into a outputfield a formula like below?

IF Today - LastModifiedDate > 60 , RED , IF Today - LastModifiedDate > 30 , YELLOW, ELSE GREEN

Thanks, Sascha

<apex:outputField value="{IF{!AccOpp.LastModifiedDate}-{!Today}>60,'RED'I{IF{!AccOpp.LastModifiedDate}-{!Today}>30,'YELLOW','GREEN'}" />
4

No. The value attribute on an apex:outputField has to be an SObject field. If you want to display text then you can use apex:outputText

Your formula doesn't look correct. I believe it should be something like this:

{!IF((TODAY() - DATEVALUE(AccOpp.LastModifiedDate)) > 60, 
     "RED", 
      IF((TODAY() - DATEVALUE(AccOpp.LastModifiedDate)) > 30, 
          "YELLOW", 
          "Green"))
}
  • 1
    The LastModifiedDate needs an additional function. <apex:outputText value="{!IF((Today() - DATEVALUE(AccOpp.LastModifiedDate)) > 60, "RED", IF((Today() - DATEVALUE(AccOpp.LastModifiedDate)) > 30, "YELLOW", "GREEN"))}" /> It works, Thanks. – peXeq Jun 19 '15 at 18:46
  • I tried to change the words into an image, but I get an error Function IMAGE may not be used in this type of formula. {!IF((Today() - DATEVALUE(AccOpp.LastModifiedDate)) > 60, IMAGE("/servlet/servlet.FileDownload?file=/015b0000001EJIK"), IF((Today() - DATEVALUE(AccOpp.LastModifiedDate)) > 30, IMAGE("/servlet/servlet.FileDownload?file=/015b0000001EJLH"), IMAGE("/servlet/servlet.FileDownload?file=/015b0000001EJJAE")))} Any ideas? – peXeq Jun 19 '15 at 19:22
  • Your field type is probably not compatible with an image, e.g. its of type Text. I imagine that Text Area (Rich) would be the only valid field type. – BarCotter Jun 22 '15 at 9:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.