You need to sign in to do that
Don't have an account?
Charni Wiggins
Render visualforce page if condition is true
Hi all,
Is there anyway to not show a visualforce page on a record if a certain field (picklist) has a specific value? Not much exprience with VF and have come across 'Rendered' but this controls elements of the VF page as I understand, not the whole page? Much appreciate any help.
Is there anyway to not show a visualforce page on a record if a certain field (picklist) has a specific value? Not much exprience with VF and have come across 'Rendered' but this controls elements of the VF page as I understand, not the whole page? Much appreciate any help.
Yes you can conditionally render an VF page as well.
Say, you have an account type record and you want to render your VF based on that account's rating field.
Then your VF page will look something like this: This page will get rendered on your page layout when that account record's rating is hot.
Let me know if it helps.
Thanks.
All Answers
Yes you can conditionally render an VF page as well.
Say, you have an account type record and you want to render your VF based on that account's rating field.
Then your VF page will look something like this: This page will get rendered on your page layout when that account record's rating is hot.
Let me know if it helps.
Thanks.
I just tried to implement this but seem to be getting an error, it's quite strange because I am not using NOT() but the error reads:
This is my apex:page line The field in the condition is a picklist, and I need it to work with contains as it should render for mulitple values... I tried ISPICKVAL at first but keep getting this error...
Many thanks
Try this:
rendered="{!IF(CONTAINS(TEXT(Contact.TR1__Candidate_Status__c), "Perm"),TRUE,FALSE)}"
The reason you are getting this error because you are using '!' twice.'!' Once used you can fetch any property from your conrtroller class in '{}' these braces.
For example:
{!c.name !c.id} Will give an error:
Correct version of this would be: {!c.name c.id}
Suppose in a value attribute seperated by a '-' then,
you can't do: value="{!c.name- !c.id}" (Will give an error)
correct way is: value="{!c.name}-{!c.id}"
I hope you understood what am trying to explain.
Let me know if you need any further clarifiction. will try my best to explain.
Thanks!
I see, it makes sense! Thank you for the explanation! :)
I used your formula above and now I am getting this error:
I see why you are getting that error.
Remove the TEXT() function and directly use contains function.
Like this:
rendered="{!IF(CONTAINS(Contact.TR1__Candidate_Status__c, "Perm"),TRUE,FALSE)}"
Thnaks!
Hey Charni,
The error says it all:
Incorrect parameter type for function 'TEXT()'. Expected Number, Date, DateTime, Picklist, received Text
Contact.TR1__Candidate_Status__c is straight away giving us a text string(How we know this? Because the error message says 'received Text').
And the construct of CONTAINS() function is: CONTAINS(text,text_to_compare).
Hence no need to use TEXT() function. :)
How can we add multiple field conditions to your code for ex. I need to show an alert if Fields 1 or Field2 is null