Hi All,
I have a requirements like this
1.After first case created, update the Case status on account to ‘Not Started’,
2. Status change from New -> Working.
Update Account case Status to In Progress
my code
--------------------------------------------
public static void updatenewtoworking(Map<Id,Case> newdata,Map<Id,Case> olddata)
{
Set<Id> acid = new Set<Id>();
List<Account> aclist = new List<Account>();
Map<Id,List<Case>> maplist = new Map<Id,List<Case>>();
for(Case c : newdata.values())
{
if(newdata.get(c.AccountId).Status=='Working' && olddata.get(c.AccountId).Status=='New' && c.AccountId != null)
{
if(!maplist.containsKey(c.AccountId))
{
maplist.put(c.AccountId, new List<Case>());
}
maplist.get(c.AccountId).add(c);
acid.add(c.AccountId);
System.debug('acid id-------'+acid);
}
}
if(acid.size()>0)
{
aclist = [select id,Case_Status__c from Account where Id IN : acid];
System.debug('-----queries result'+aclist);
for(Account acc : aclist)
{
if(maplist.containsKey(acc.Id))
{
acc.Case_Status__c ='In Progress';
}
}
if(aclist.size()>0)
{
update aclist;
System.debug('-----------SECOND CONDTION'+aclist);
}
}
its not updating so can anyone help me to find it out
thanks in advance