You need to sign in to do that
Don't have an account?
Anthony Huerter
Visualforce Page block to appear when a field meets a certain criteria
I am trying to get a visualforce page to appear when a custom field meets a certain criteria. Here is what I have now and this works but I need to only appear if: Custom field is > 20
<apex:page >
<style> .bPageBlock { background-color: green !important; } </style>
<apex:form > <apex:pageblock title="testing"> <div>This is a green partner. </div>
</apex:pageblock>
</apex:form>
</apex:page
I would also like the background color to change to yellow if custom field is between 11 and 19 and change to red if the custom field is <10
This is my first time making a Visualfroce page so I am a little lost. I have tried mulpile formulas but nothing seems to work. Any help would be appreciated.
Thanks
<apex:page >
<style> .bPageBlock { background-color: green !important; } </style>
<apex:form > <apex:pageblock title="testing"> <div>This is a green partner. </div>
</apex:pageblock>
</apex:form>
</apex:page
I would also like the background color to change to yellow if custom field is between 11 and 19 and change to red if the custom field is <10
This is my first time making a Visualfroce page so I am a little lost. I have tried mulpile formulas but nothing seems to work. Any help would be appreciated.
Thanks
Use this
<style>
.bPageBlock {
background-color: {!If((object.yourcustomfield < 10 ),' red !important',If((object.yourcustomfield >= 11 && object.yourcustomfield <= 19),' yellow !important',' green !important'))};
}
</style>
<apex:pageblock title="testing" rendered="{!object.yourcustomfield!=null && object.yourcustomfield > 20}">
<div>This is a green partner. </div>
</apex:pageblock>
Or You can also use jquery and javascript to acheive your result as said by rahul
All Answers
Please let me know if you are finding any difficulty.
Please choose this as Best Answer if it helps you to solve your problem.
Use this
<style>
.bPageBlock {
background-color: {!If((object.yourcustomfield < 10 ),' red !important',If((object.yourcustomfield >= 11 && object.yourcustomfield <= 19),' yellow !important',' green !important'))};
}
</style>
<apex:pageblock title="testing" rendered="{!object.yourcustomfield!=null && object.yourcustomfield > 20}">
<div>This is a green partner. </div>
</apex:pageblock>
Or You can also use jquery and javascript to acheive your result as said by rahul
<apex:page >
<style>
.bPageBlock {
background-color: {!If((Account.New_Partner_Points__c < 10 ),' red !important',If((Account.New_Partner_Points__c >= 11 && Account.New_Partner_Points__c <= 19),' yellow !important',' green !important'))};
}
</style>
<apex:pageblock title="testing" rendered="{!Account.New_Partner_Points__c!=null && Account.New_Partner_Points__c > 20}">
<div>This is a green partner. </div>
</apex:pageblock>
</apex:page>
I am getting this erroe now. Error: Unknown property 'Account.New_Partner_Points__c' referenced in Backlgroundcolor2
For accessing the field value in your VF page, you have to taken care of 2 things, that the field you are accessing to vf page of any object. That object should be public with getter and setter. And you can access the field in you page with this syntax {!Account.New_Partner_Points__c}.
Please choose this as Best Answer if it helps you to solve your problem.
You Have Forgot to set
StandardController="Account"
in apex:page
Hope This Helps.
you have to add
<apex:page StandardController="Account">
or if you are using custom controller than
<apex:page Controller="ControllerName"> and in controller while declaring a variable do like this
public Account account{get;set;}
Please choose this as Best Answer if it helps you to solve your problem.