there is a lookup field with User object UserLookup__c : when the field is not empty , share that particular record to selected user in the lookup field. how can we achieve this 1. I think we can create a criteria based sharing rule: if it is correct please tell me how we can give the criteria. 2. if it is possible with apex sharing how can we achieve this. pls help.
Criteria based sharing rule: this is possible, but then you need one rule per possible user. So depending on the org size, this is probably not manageable.
Apex sharing: create a process on the object, and whenever UserLookup__c gets filled in, create a UserLookup__share record for that specific user with the level of access you want to give (read/edit). A great example can be found here.