You need to sign in to do that
Don't have an account?
SF Beginner 2019
being overide by first record
I have these class wherein when I create or update the StatusGet__c to Completed it works, wherein it checks the (Indicator1__c)checkbox, and when I create != Completed it Unchecks(Indicator1__c), but my problem is that everytime I craete a new record != Complete it overrides the checkbox, wherein what I want is that if there is a record StatusGet__c = Completed on the list of record the Indicator1__c will still be checked even if they add records != compelted
public class TaskTriggerHandles{
public void getAcct(List<Task> taskacct) {
List<Account> accountsToUpdate = new List<Account>();
taskacct = [SELECT Id, whatid,StatusGet__c FROM Task WHERE Id IN :taskacct];
system.debug('taskacct' + taskacct );
for (Task p : taskacct) {
if(p.StatusGet__c == 'Completed ')
{
Account a = new Account(
Id = p.whatid,
Indicator1__c= true);
accountsToUpdate.add(a);
system.debug('a' + a);
}
else if(p.StatusGet__c != 'Completed')
{
Account a = new Account(
Id = p.whatid,
Indicator1__c= false);
accountsToUpdate.add(a);
system.debug('a' + a);
}
update accountsToUpdate;
system.debug('accountsToUpdate' + accountsToUpdate);
}
}
}
public class TaskTriggerHandles{
public void getAcct(List<Task> taskacct) {
List<Account> accountsToUpdate = new List<Account>();
taskacct = [SELECT Id, whatid,StatusGet__c FROM Task WHERE Id IN :taskacct];
system.debug('taskacct' + taskacct );
for (Task p : taskacct) {
if(p.StatusGet__c == 'Completed ')
{
Account a = new Account(
Id = p.whatid,
Indicator1__c= true);
accountsToUpdate.add(a);
system.debug('a' + a);
}
else if(p.StatusGet__c != 'Completed')
{
Account a = new Account(
Id = p.whatid,
Indicator1__c= false);
accountsToUpdate.add(a);
system.debug('a' + a);
}
update accountsToUpdate;
system.debug('accountsToUpdate' + accountsToUpdate);
}
}
}
what happen is that
record 1 on task = completed
record 2 on task = incomplete
record 3 on task = test
the indicator checkbox should still be checked.
if we add another record wherein != completed the checkbox should still be checked
and if we add = completed the checkbox is still checked.
but if we delete the completed and no task = completed is existing on a list this will unchedk the checkbox.