I don't think it is possible in global search .We don't have control over it .May be you can raise a case to salesforce to do somsthing for which you can achive this .
If your OWD setting for Account is private, you can share active Account records with respective users, Do not share otherwise. This could be an option!
trigger Test_Share on Test__c (after insert) {
if(trigger.isInsert){
/**
* Test_Share is the "Share" table that was created when the Organization Wide Default
* sharing setting was set to "Private". Allocate storage for a list of Test_Share
* records.
**/
List<Test_Share> jobShares = new List<Test_Share>();
/** For each of the Test records being inserted, do the following: **/
for(Test__c t : trigger.new){
/** Create a new Test_Share record to be inserted in to the Test_Share table. **/
Test_Share studentRecord = new Test_Share();
/** Populate the Test_Share record with the ID of the record to be shared. **/
studentRecord.ParentId = t.Id;
/** Then, set the ID of user or group being granted access. In this case,
* we're setting the Id of the student__c that was specified by the Test
* Result in the student__c lookup field on the Test record.
**/
studentRecord.UserOrGroupId = t.student__c;
/** Specify that the Student should have edit access for this particular Test record. **/
studentRecord.AccessLevel = 'edit';
/** Specify that the reason the Student can edit the record is because its his test result
* (Student_Access__c is the Apex Sharing Reason that we defined earlier.)
**/
studentRecord.RowCause = Schema.Test_Share.RowCause.Student_Access__c;
/** Add the new Share record to the list of new Share records. **/
jobShares.add(studentRecord);
}
/** Insert all of the newly created Share records and capture save result **/
Database.SaveResult[] jobShareInsertResult = Database.insert(jobShares,false);
}
}
I don't think it is possible in global search .We don't have control over it .May be you can raise a case to salesforce to do somsthing for which you can achive this .
Let me know if you get any solution for this .
Thanks
Manoj
This could be an option!
You can try APEX sharing for same.
https://developer.salesforce.com/page/Using_Apex_Managed_Sharing_to_Create_Custom_Record_Sharing_Logic
https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_bulk_sharing_creating_with_apex.htm
http://blog.jeffdouglas.com/2009/11/25/programmatically-creating-sharing-rules-with-apex/
http://www.jitendrazaa.com/blog/salesforce/apex-based-sharing-in-salesforce/
Please let us know if this will help you