I have two custom Objects Member and Issue.
Issue has a master detail relationship with member. The field called MASTER of Issue is a master-detail field that points to Member object.
I'm creating a trigger to update a field of member based on certain criterion:
trigger RollbackUpdate on sade__Issue__c (before insert, before update) {
for (sade__Issue__c childObj : Trigger.new) {
if(childObj.sade__Approval_Status__c != null && childObj.sade__Approval_Status__c.equals('Rejected')){
Id mID = Id.valueOf(childObj.sade__Member__c);
sade__Member__c me = Database.query('SELECT Id,sade__Membership_ID__c,sade__No_of_Books_Issued__c FROM sade__Member__c WHERE Id =:'+mID+' LIMIT 1');
me.sade__No_of_Books_Issued__c -= 1;
update me;
}
}
}
Now, when I'm rejecting an approval I get this issue:
RollbackUpdate: execution of BeforeUpdate caused by: System.QueryException: Variable does not exist: a0H28000002IOujEAG
But I do have a member with ID a0H28000002IOujEAG.
Workbench Query SELECT Id,Name FROM sade__Member__c WHERE Name = 'Abhishek De' returns:
Id Name
1 a0H28000002IOujEAG Abhishek De