You need to sign in to do that
Don't have an account?
Jothi Eswaran
I am not able to write test class for an apex sharing class. Some one can help ?
This apex sharing class - will provide read only access to previous lead owner and full access to current lead owner when lead ownership is changed. separate update trigger is written
public class LeadRecordSharingHelper {
public static void leadRecordShare(Map<Id, Lead> lmap, List<Lead> llist)
{
Id profileId = userinfo.getProfileId();
String profileName = [Select Id,Name from Profile where Id=:profileId].Name;
if (profileName == 'XXX')
{
List<LeadShare> leadsharelist = new List<LeadShare>();
for (Lead ld : llist)
{
if (ld.ownerId != lmap.get(ld.Id).ownerId)
{
LeadShare lshare = new LeadShare();
lshare.LeadAccessLevel = 'Read';
lshare.LeadId = ld.Id;
lshare.UserOrGroupId = lmap.get(ld.Id).ownerId;
lshare.RowCause = Schema.LeadShare.RowCause.Manual;
leadsharelist.add(lshare);
}
}
insert leadsharelist;
}
}
}
public class LeadRecordSharingHelper {
public static void leadRecordShare(Map<Id, Lead> lmap, List<Lead> llist)
{
Id profileId = userinfo.getProfileId();
String profileName = [Select Id,Name from Profile where Id=:profileId].Name;
if (profileName == 'XXX')
{
List<LeadShare> leadsharelist = new List<LeadShare>();
for (Lead ld : llist)
{
if (ld.ownerId != lmap.get(ld.Id).ownerId)
{
LeadShare lshare = new LeadShare();
lshare.LeadAccessLevel = 'Read';
lshare.LeadId = ld.Id;
lshare.UserOrGroupId = lmap.get(ld.Id).ownerId;
lshare.RowCause = Schema.LeadShare.RowCause.Manual;
leadsharelist.add(lshare);
}
}
insert leadsharelist;
}
}
}
All Answers