4

I'm getting an error INACTIVE_OWNER_OR_USER, operation performed with inactive user, and I have been doing a lot of research and the cause that I have found for this is its attempting to assign a my lead to inactive user. So I understand that part I think the issue is now I don't actually know how to fix it, I didn't write this trigger/test class and I'm not sure how to go forward.

Do I need to create a new Test User? I've never worked on the Lead object before..

Edit** I added IsActive = True the trigger user query, no luck.

Edit** I just went talking to anyone that might have an idea about UserTypes, and they have no idea what UserType = 'PowerPartner' is. So I changed it to a different UserType.. didn't work

Edit** I'm nuking this trigger, I have to re write it..

Test Class

@isTest
private class PartnerLeadShare_test {
static testMethod void myUnitTest1() {
List<Lead> leadList = new List<Lead>();
List<LeadShare> leadShareList = new list<LeadShare>(); 

Lead ld = new Lead();
ld.lastName = 'Tester';//=/
ld.Company = 'MyCompany';
ld.Status = 'Open';
ld.Program_EAU__c ='11';
insert ld;
system.debug('ld****' +ld);

GroupMember groupMemberStore = [select GroupId,UserOrGroupId from GroupMember limit 1];

LeadShare ls = new LeadShare(); 
ls.LeadId = ld.id;
ls.UserOrGroupId = groupMemberStore.UserOrGroupId ;
ls.LeadAccessLevel = 'Edit';
leadShareList.add(ls);

 if(leadShareList.size()>0){
    system.debug('INSIDE LEADSHARE LIST.');
     insert leadShareList;
 }
 }
}

Don't know this will help but here is my trigger..

trigger PartnerLeadShare on Lead (after insert,after update) {

Map<id,User>PartnerUsermap = new Map<id,user>([select id,UserType from user where      UserType = 'PowerPartner' and IsActive = True] );   
List<GroupMember>GroupMemberList = new List<GroupMember>([select GroupId,UserOrGroupId   from GroupMember]); 

System.debug('PartnerUsermap ===  '  +PartnerUsermap);
System.debug('GroupMemberList    '+GroupMemberList );

List<LeadShare> leadShareList = new list<LeadShare>(); 

 if(!PartnerUsermap.isEmpty()){
for(Lead ld: trigger.new){ 
    for(GroupMember grpmem : GroupMemberList){
        if(grpmem.UserOrGroupId == ld.CreatedById){  
            LeadShare ldShare = new LeadShare (LeadId = ld.id,UserOrGroupId = grpmem.GroupId,LeadAccessLevel = 'Edit'); 
            leadShareList.add(ldShare );
        }
    }
}
}
if(!leadShareList.isEmpty()){
Database.SaveResult[] lsr = Database.insert(leadShareList,false);           
Integer i=0;
for(Database.SaveResult sr : lsr){
    if(!sr.isSuccess()){
    Database.Error err = sr.getErrors()[0]; 
            if(!(err.getStatusCode() == StatusCode.FIELD_FILTER_VALIDATION_EXCEPTION  
                                           &&  err.getMessage().contains('AccessLevel'))){

                trigger.newMap.get(leadShareList[i].LeadId).
                  addError(
                   'Unable to grant sharing access due to following exception: '
                   + err.getMessage());
            }
    }
   i++;
}
}

2 Answers 2

1

Is there any chance you have an inactive User in some of your groups? Try removing them from those groups and see if you still get the issue.

1
  • I think I may of figured it out. I'm testing it right now, but I just fed in a hard coded value in the test class. I just want to see if we even need it so I will be deactivating it
    – EricSSH
    Commented Apr 28, 2014 at 20:26
2

Sorry, I don't have enough rep to comment just yet so I'm writing this as an answer. Are you saying that this error only happens when the test is run?

Re: Your question about 'PowerPartner'. You can find the different user types here: Salesforce User Types

4
  • It breaks when I run the test class. I'm going to update my question
    – EricSSH
    Commented Apr 24, 2014 at 17:01
  • It's also weird that it works on a different dev client ..
    – EricSSH
    Commented Apr 24, 2014 at 17:07
  • When is it working? Also, can you confirm that the trigger is working correctly when not being run by the test code?
    – Kyle
    Commented Apr 24, 2014 at 17:09
  • Oh good idea, So now that I'm really looking into the trigger, it was really poorly written. I'll test that
    – EricSSH
    Commented Apr 24, 2014 at 17:12

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .