You need to sign in to do that
Don't have an account?
Nihar Sharma
how to update stage based on task completion? Having trouble in Multiple Task
Hi,
i am trying to update the Stage based upon the Task.Status = 'Actividad-Finalizada'..and it worked if i have only one Task but i wont work if there are more task on same Opportunity..
Please can anybody check what change needs to this below code..
Thanks a ton !!
i am trying to update the Stage based upon the Task.Status = 'Actividad-Finalizada'..and it worked if i have only one Task but i wont work if there are more task on same Opportunity..
Please can anybody check what change needs to this below code..
trigger UpdateOppOnTaskComplete on Task (after insert, after update) { Set<String> whatIDs = new Set<String>(); for (Task t : Trigger.new) { if(t.Status.equals('Actividad-Finalizada')) whatIDs.add(t.whatID); } List<Opportunity> opps = [SELECT Id, StageName, Probability, Compania__c, Type FROM Opportunity WHERE Id =: whatIDs AND (Probability = 98 OR Probability = 40) AND (Type = 'Flujo de venta Estándar' OR Type = 'Flujo de venta No Estándar')]; //List<Opportunity> opps1 = [SELECT Id, StageName, Probability, Compania__c FROM Opportunity WHERE Id =: whatIDs AND Probability = 40 AND Type = 'Flujo de venta No Estándar']; for(Opportunity opp : opps){ if(opp.compania__c.equals('Bestel') && opp.Type.equals('Flujo de venta Estándar')){ opp.StageName = 'Orden de Trabajo en proceso (99%)'; opp.Probability = 99; }else if(opp.compania__c.equals('Metrored')) { opp.StageName = 'Cerrada (100%)'; opp.Probability = 100; } if(opp.compania__c.equals('Bestel') && opp.Type.equals('Flujo de venta No Estándar')){ opp.StageName = 'Producto define precio final (42 %)'; opp.Probability = 42; } } if(opps != null && opps.Size() > 0) update opps; }
Thanks a ton !!
Thanks for your reply..
but stage wont be updating with 42%..No doubt there is nothing error like that but what i'm expecting is need to change stage from 40 to 42 when there are no OPEN ACTIVITIES available..(that mean all open activies are closed or completed)
Thanks again !!
No. still it's not changing the stage from 40 to 42...
Thanks