+ Start a Discussion
bcgbcg 

How to lock records

Hello Everyone,

 

 I am facing some problem in locking the records. pls anyone know how to solve this problem then tell me. i want when i save some records and that records are visible in related list, but after 24hrs that records are disable for end users. how it is possible.

 

 

Thanks In advance.

AhmedPotrickAhmedPotrick

We can have new read only page layout and new record type. Use time based workflow and update record type after 24 hrs.
In case of related list, we will still have edit/delete buttons visible.To remove the buttons we need to remove edit and delete permission at profile level.
So one option is to make custom VF page with related list with no edit/delete buttons. When user clicks on related list record, it will redirect to read only page layout.

bcgbcg

Thanks for reply,

 

Will you please help me out, that what to write in workflow rule. what are the criteria in workfolw rule should i use. will you pls give me any example. actually i am new to salesforce so i don't kne much more.

 

 

Thanks

AhmedPotrickAhmedPotrick

Create workflow for your object, evaluation criteria keep as "When a record is created, or when a record is edited and did not previously meet the rule criteria", Rule criteria will be your entry condition (i.e. for which conditions you want the users to only view records).it could be something like type equals 'something' and other criteria.


Then add time trigger with time as 24 hours after rule trigger date or last modified date. Then simply add field update for record type.

bcgbcg

actually i want, if record is created for today its accessible today only. i.e. user can edit this only created date. and tommorow thes records are not editable. how to do that.?

AhmedPotrickAhmedPotrick

With time based workflow rules, records will be read only exactly after say 24 hours after it was created. If you want all records created today (say 29.11.10) to be read only on (30.11.10). Then you can also have batch apex class and schedule it (may be at midnight or any specific time). This batch class will pick all data created today and will update the record type.

ex:

SELECT Id FROM Account WHERE CreatedDate > TODAY

SELECT Id FROM Opportunity WHERE CloseDate = TOMORROW

 

So after this class runs all those records will have updated record type.

But this way you need to ensure that users are not able to access the records from any where else (related list).

 

Also if you want to completely remove edit permission from that records, then you can use Apex sharing in your batch class.Check Apex developer guide for more help on Apex sharing.

mtbclimbermtbclimber

What is the goal of "Locking" records here? Changing the record type and redirecting to a Visualforce page isn't going to "Lock" the record from being edited via all possible channels and it's simple to bypass Visualforce override pages anyway.

 

When a record is "Locked" what behavior are you after? Do you want it to be visible everywhere but not editable by everyone or just not editable by non-admins.... or not visible at all by end users?  How will records become "unlocked"?