You need to sign in to do that
Don't have an account?
babloo123
Mixed DML error -Using future method but getting error
Hi I have a scenario where the contact has a checkbox called IS user active which has to be updated as and when user becomes inactive to false.
I wrote a trigger to do it showed me a mixed DML error and wrote the below code using future method as well now I am getting another error. Need some help on this
Trigger.
trigger Checkuseractive on User (after update) {
user u=[select id,Isactive,contactid from user where id=:trigger.new[0].id];
Id cid=u.ContactId;
if(trigger.new[0].IsActive=='false')
{
contactactivecheckboxclass.updatecnt(cid);
}
}
Future Method
public class contactactivecheckboxclass {
@future
public static void Updatecnt(id x)
contact c=[select Is_user_Active__c from Contact where id=:x];
c.Is_User_Active__c=false;
update c;
}
Error : Unexpected token :Contact on class line 4
I wrote a trigger to do it showed me a mixed DML error and wrote the below code using future method as well now I am getting another error. Need some help on this
Trigger.
trigger Checkuseractive on User (after update) {
user u=[select id,Isactive,contactid from user where id=:trigger.new[0].id];
Id cid=u.ContactId;
if(trigger.new[0].IsActive=='false')
{
contactactivecheckboxclass.updatecnt(cid);
}
}
Future Method
public class contactactivecheckboxclass {
@future
public static void Updatecnt(id x)
contact c=[select Is_user_Active__c from Contact where id=:x];
c.Is_User_Active__c=false;
update c;
}
Error : Unexpected token :Contact on class line 4
All Answers