function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
PrakkiPrakki 

How to change selected custom object fileds read only based on check box filed in the user object

Dear All,

 

I am strggling to solve this scenario, if any one helping me on this i will be greatful to them.

 

We are having various users and an custom object called Vehicle it containing many pick list fields, some text fields too currently all the users having modify all permission on this object. In the user object we had created a check box filed.

If the check box in the user object is unchecked, users should not enter any values to the pick list filed, means for all the users Vehicle object pick list fields should changed to read only. I would like to clear only picklist fields should be read only, on remaining fields user can do any operation.

 

If check box is checked then modify all permission on the vehicle object should effect. 

 

It's very urgent,

 

Thank you.

 

Regards,
Prakki

AroraAnupAroraAnup

So there are 2 ways you can do this:

 

1. Using VF - You can override the standard page with a Visual Force page and use a controller where you can define the criteria that checkes the User record of the logged in user, will see if this checkbox is checked or not and will accordingly render the fields in a Read-only or Editable mode.

 

2. Using Validation rules - This is the workaround without using any code. You can write validation rules on the picklists that you want should not be editable if the checkbox on the User record is checked. Though using this approach, the fields will still appear Editable to the users on the layout but will throw the error message to them if they try to modify it.

 

Hope this helps!

PrakkiPrakki
Hi Cloud Knight,

Thank you so much for the answer.

Can you please share the code , how we can do this with VF page. Then it will be very useful for the other members too.

Thank you.

Prakki
AroraAnupAroraAnup

I think these should help you:

 

Use 'disabled' attribute with yourcomponent..

 

<apex:inputtext value="{!inp1}" disabled="{!flag}"/>

<apex:inputtext value="{!inp2}" >

<apex:actionsupport event="onchange" action="{!settingflag}"/>

</apex:inputtext>

 

I also found another link that should help you out - http://www.tehnrd.com/show-and-hide-buttons-on-page-layouts/

 

Hope this helps!