You need to sign in to do that
Don't have an account?
JAGJOT SINGH
Error: Invalid Data. Apex trigger AmountTask caused an unexpected exception, contact your administrator: AmountTask: execution of AfterUpdate caused by: System.NullPointerException: Argument cannot be null.: Trigger.AmountTask: line 44, column 1
trigger
public class createoppojjb{
public static void account(set<id> AcountID)
{
List<Opportunity> oppList = [Select id, Name, AccountId, Amount from Opportunity where AccountId IN : AcountID];
Map<Id,List<Opportunity>> mapOpp = new Map<Id,List<Opportunity>>();
for(Opportunity opp : oppList){
if(mapOpp.containsKey(opp.AccountId)){
List<Opportunity> oppAcountID = mapOpp.get(opp.AccountId);
oppAcountID.add(opp);
mapOpp.put(opp.AccountId,oppAcountID);
}
else{
List<Opportunity> oppAcountID = new List<Opportunity>();
oppAcountID.add(opp);
mapOpp.put(opp.AccountId,oppAcountID);
}
}
List<Opportunity> opp;
Double Amount = 0;
String Idd;
for(Id oppId : mapOpp.keySet()){
opp = mapOpp.get(oppId);
System.debug(opp);
for(Opportunity amt : opp){
Amount += amt.Amount;
System.debug(Amount);
}
}
Boolean flag = true;
List<Opportunity> names = new List<Opportunity>([Select Id, Name, Amount from Opportunity where Id IN : opp]);
System.debug('names '+names + ' ' + flag);
for(Opportunity oppName : names){
if(oppName.Name == 'Test'){
System.debug(Amount);
}
}
}
}
class
trigger CreateOpp on Account (after update, after insert) {
if((Trigger.IsAfter && Trigger.isUpdate)) {
Set<Id> accID = new Set<Id>();
for(Account acc:Trigger.New) {
if(acc.Name != 'null') {
accID.add(acc.id);
}
}
if(accID.size()>0) {
createoppojjb.Addaccopp(accID);
}
}
}
public class createoppojjb{
public static void account(set<id> AcountID)
{
List<Opportunity> oppList = [Select id, Name, AccountId, Amount from Opportunity where AccountId IN : AcountID];
Map<Id,List<Opportunity>> mapOpp = new Map<Id,List<Opportunity>>();
for(Opportunity opp : oppList){
if(mapOpp.containsKey(opp.AccountId)){
List<Opportunity> oppAcountID = mapOpp.get(opp.AccountId);
oppAcountID.add(opp);
mapOpp.put(opp.AccountId,oppAcountID);
}
else{
List<Opportunity> oppAcountID = new List<Opportunity>();
oppAcountID.add(opp);
mapOpp.put(opp.AccountId,oppAcountID);
}
}
List<Opportunity> opp;
Double Amount = 0;
String Idd;
for(Id oppId : mapOpp.keySet()){
opp = mapOpp.get(oppId);
System.debug(opp);
for(Opportunity amt : opp){
Amount += amt.Amount;
System.debug(Amount);
}
}
Boolean flag = true;
List<Opportunity> names = new List<Opportunity>([Select Id, Name, Amount from Opportunity where Id IN : opp]);
System.debug('names '+names + ' ' + flag);
for(Opportunity oppName : names){
if(oppName.Name == 'Test'){
System.debug(Amount);
}
}
}
}
class
trigger CreateOpp on Account (after update, after insert) {
if((Trigger.IsAfter && Trigger.isUpdate)) {
Set<Id> accID = new Set<Id>();
for(Account acc:Trigger.New) {
if(acc.Name != 'null') {
accID.add(acc.id);
}
}
if(accID.size()>0) {
createoppojjb.Addaccopp(accID);
}
}
}
Please use that above trigger
Thanks,
Harshit Garg
All Answers
Please use that above trigger
Thanks,
Harshit Garg
Your trigger name is CreateOpp . That error is not coming through this trigger...that error coming through another trigger.
May be trigger name is - Amounttask.
Please check your another trigger.
Thanks,
Harshit Garg
Hello Sir,
Mr Harshit Garg,
your suggetion working. my other trigggers create a errors.now code is working sir,
Thanks Alot,
Jagjot Singh
If my suggestion work for you..Please choose my ans as the best ans.
Thanks,
Harshit Garg