You need to sign in to do that
Don't have an account?
How to change text or row color based on date (or purchased support agreement)?
We have a date field that calculates the 90 day support expiration date and were hoping to have the date displayed in color, IE:
if product was purchased within 90 days
if product was purchased > 90 days ago
<apex:column >
<apex:facet name="header">
<B>90 Day Exp Date</B>
</apex:facet>
<apex:outputField value="{!ourORG.customPRODUCT.X90_Day_Date__c}"/>
</apex:column>
I've been trying to research putting the logic/color into the 'outputField' line of our VF page... Alternatively, I looked into a custom formula field to compare the dates between DOP and Today's date to check for the 90 day logic and display a different image to indicate warranty status.
Which is possible in VF, or am I going about this all wrong? :smileyhappy:
We have also considered a 3rd color to indicate that the product has a purchased support agreement (IE: value exists in another field)... But, we'd be happy just to get going with the simpler version above as a launch pad.
Many thanks in advance..
Success!
After complexifying things in my last post, I was eventually able to get what I wanted using only the fields I started with:
<apex:outputText value="{0,date}" style="{!IF(ourORG.customPRODUCT.X90_Day_Date__c - TODAY()<0,'color:red','color:green')}">
<apex:param value="{!sling.customSlingBox.X90_Day_Date__c}" />
</apex:outputText>
I tried a few different formula formats and found that I could get TODAY to work, after all (along with greater/less than with date fields), so long as the "!" was removed prior to 'ourORG....'.
Also, using param allowed me to recode my date in a more useful format for us (IE: not the long system GMT time).
Thanks again for pointing me in the right direction!
All Answers
<apex:outputField value="{!ourORG.customPRODUCT.X90_Day_Date__c}" style="{!IF((ourORG.customPRODUCT.X90_Day_Date__c>90),'color:red','color:green')}"/>
Try with this format... Hope that helps
Cheers!!
Hi Edwin1 -- many thanks for the suggestion!
Trying to save this gives us:
I wasn't too clear (apologies), but our X90_Day_Date__C field is a date field that = 90 days past the Date of Purchase, so I guess a variation of your formula for this field might be...?
... but that doesn't pass the check either. Hrm.
Excited to try to at least color the field, I also tried the following basic test:
... but my date column field still shows up with black font. Double Hrm.
Thanks again -- you've helped us get onto the right path and I'll keep tinkering.
Hmm.. if that does'nt work then try using a style class..
But when you use styles for outputfields, that may not display as expected i think...
<apex:outputField value="{!ourORG.customPRODUCT.X90_Day_Date__c}" style="color:red;"/>
Anyhow, can you try the above method or try using a outputtext instead of outputfield....
And instad of the date comparision use any other field.. just to test if the IF syntax is correct.. However, you cannot use TODAY in the VF code i believe..
Regards,
Edwin
Progress!
I tried this as mentioned:
<apex:outputField value="{!ourORG.customPRODUCT.X90_Day_Date__c}" style="color:red;"/>
...but it didn't work. So I tried outputText:
<apex:outputField value="{!ourORG.customPRODUCT.X90_Day_Date__c}" style="color:red;"/>
... and it worked! (but with the long GMT time displayed, which I'll correct, but it reminded me why I used outputField before. Doh.).
So, I messed around with the formula to test your !IF syntax. Since it was compaining about a boolean, I tested with a checkbox field and changed the syntax just a bit to the following:
<apex:outputText value="{!ourORG.customPRODUCT.X90_Day_Date__c}" style="{!IF((!ourORG.customPRODUCT.Out_of_Warranty_Repair_or_Exchange_Progr__c=true),'color:red','color:green')}" />
It works! (that is, I see this field's font color change based on the state of the substituted field's checkbox)
So, knowing what I know now, I suppose I could create a new formula field to set a boolean value after 90 days from DOP and insert it above and be 100% done.
I tested with number fields, but wasn't able to get the <or > to work with !IF (it still asked for boolean) -- It would be nice if I could get the < or > working based on a number field, then simply create a formula to add up number of days since DOP to that field. It would be even nicer if I could figure out a formula for the existing date, though.
I've got enough info to keep plugging and at least we have a small breakthrough -- thanks again Edwin1!
Success!
After complexifying things in my last post, I was eventually able to get what I wanted using only the fields I started with:
<apex:outputText value="{0,date}" style="{!IF(ourORG.customPRODUCT.X90_Day_Date__c - TODAY()<0,'color:red','color:green')}">
<apex:param value="{!sling.customSlingBox.X90_Day_Date__c}" />
</apex:outputText>
I tried a few different formula formats and found that I could get TODAY to work, after all (along with greater/less than with date fields), so long as the "!" was removed prior to 'ourORG....'.
Also, using param allowed me to recode my date in a more useful format for us (IE: not the long system GMT time).
Thanks again for pointing me in the right direction!
Hi Edwin
Sumanth here , I`m trying to show outputfield values in red color.
<apex:outputField value="{!Case.Feature_Name__c}" style="color:red;"/> but this isn`t working.
Basically I want to show the Field Label and value in red color.
For Inputfield, its working if I have it in this way -- This is for the data that will be entered, For label I will have <font color = red>Field name </font>
Is there any alternate way of having Color for Label too ?
<apex:inputField value="{!Case.Feature_Name__c}" styleClass="money"/>
<style type = "text/css">
.money
{
FONT-SIZE: 9px;
color : red;
font-weight: bold;
}
</style>