+ Start a Discussion

Vf page+ enable button based on user

Hi Everyone,

i have a vf page which contains a button, with a record.
i want to enable button based on record owner.contion here i want to enable it only if record owner is other than created user of record.
EX: lets say User A is create record.if user is opened that opened the page contains this record.this time button needs to disabled.
If user B opened this page contains user A created record.this time it needs to be enabled.

can some one help tel me the condtion please.

if you are using commandbutton you  have rendered option in that you can give a condition .. If you have the standardcontroller that you can use in the vf page then you can write some thing like below....  If you dont have the stdctrl then you need to get that as a property 
<apex:commandbutton ..... rendered="{!if($User.Id == objectname.OwnerId),false, true)}">

Please try with below, it will disabled and enabled your button based on condition.
<apex:commandbutton value="Test" disabled="{!if($User.Id == Object.OwnerId),true, false)}">

Thanks & Cheers,

Some times this doesn't make sense to me , when we dont want to display something on UI, why we need to place that on UI and hide or disable with javascript or css.