• mohamed Sufiyan 8
  • NEWBIE
  • 10 Points
  • Member since 2018

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 1
    Replies
I need to deactivate a  user and portal user by clicking checkbox in contact page. 
trigger activeuser on Contact (after update) {
    ID contactId = [Select contactid from User where id =:UserInfo.getUserId()].contactId; 
   
  for(Contact c : Trigger.new){
    if(c.isactive__c == true) 
            {             
        User u = [SELECT Id,ContactId,IsActive,IsPortalEnabled FROM User  WHERE contactId =:contactId ];
                
                 
                     u.CompanyName ='test';
                    u.IsActive=false;
                    u.IsPortalEnabled=false;
           Update u;

                }
            }
}

am getting error 
System.DmlException: Insert failed. First exception on row 0; first error: MIXED_DML_OPERATION, DML operation on setup object is not permitted after you have updated a non-setup object (or vice versa)


any help..
I need to deactivate a  user and portal user by clicking checkbox in contact page. 
trigger activeuser on Contact (after update) {
    ID contactId = [Select contactid from User where id =:UserInfo.getUserId()].contactId; 
   
  for(Contact c : Trigger.new){
    if(c.isactive__c == true) 
            {             
        User u = [SELECT Id,ContactId,IsActive,IsPortalEnabled FROM User  WHERE contactId =:contactId ];
                
                 
                     u.CompanyName ='test';
                    u.IsActive=false;
                    u.IsPortalEnabled=false;
           Update u;

                }
            }
}

am getting error 
System.DmlException: Insert failed. First exception on row 0; first error: MIXED_DML_OPERATION, DML operation on setup object is not permitted after you have updated a non-setup object (or vice versa)


any help..