You need to sign in to do that
Don't have an account?
SydneyForce
How to render an input field only if user has edit access to it
Hello,
I would like to know how to render an input field only if a user has edit access to a field.
This could be done by a Apex controller if necessary.
Right now I have an input field, but I don't want it rendered for users that have "read-only' access at field-level security for their profile.
Thank you,
Adrian
In the controller you can declare a Boolean variable to decide whether the inputField should be rendered or not.
In controller class,
Public Bololean showField{get; set;}
//Somewhere initialise the field to false
Schema.DescribeFieldResult sdf = ObjectName.FieldName.getDescribe();
if(sdf.isCreateable() || sdf.isUpdateable())
{
showField = true;
}
Then in VF page,
<apex:inputField value="{!mergefield}" rendered="{!showField}"/>
Hope that helps.
All Answers
In the controller you can declare a Boolean variable to decide whether the inputField should be rendered or not.
In controller class,
Public Bololean showField{get; set;}
//Somewhere initialise the field to false
Schema.DescribeFieldResult sdf = ObjectName.FieldName.getDescribe();
if(sdf.isCreateable() || sdf.isUpdateable())
{
showField = true;
}
Then in VF page,
<apex:inputField value="{!mergefield}" rendered="{!showField}"/>
Hope that helps.
Thanks Imran.
That's exactly what I'm after.