• Gerald Harmens
  • NEWBIE
  • 5 Points
  • Member since 2016

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 7
    Questions
  • 15
    Replies
Hello,

I need help changing the code below to update Map Values. The code below creates a new instance of the prospect at line 18 and adds it to our prospect list which is causing this error:

i360.ProspectTriggers: execution of AfterUpdate caused by: System.DmlException: Update failed. First exception on row 0 with id a0416000010g4SdAAI; first error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, Appointment_Price_Quoted: execution of AfterUpdate caused by: System.ListException: Duplicate id in list: a0Z1600000AQwFjEAL Trigger.Appointment_Price_Quoted: line 28, column 1: [] Class.i360.ProspectUtilities.UpdateProspectNames: line 1509, column 1 Class.i360.Prospect_Trigger_Utilities.ProspectChangeName: line 175, column 1 Trigger.i360.ProspectTriggers: line 22, column 1
trigger Appointment_Price_Quoted on i360__Appointment__c (after update) 
{
    if(Trigger.isAfter)
    {
        if(Trigger.isupdate)
        {
            set<Id> ProspectSet = new set<Id>();
            for(i360__Appointment__c Appointment :Trigger.new){
                ProspectSet.add(Appointment.i360__Prospect__c);
            }
            map<string, i360__Prospect__c> ProspectMap = new map<string, i360__Prospect__c>(
               [SELECT Id, Appointment_Quoted_Price__c 
               FROM i360__Prospect__c
                WHERE Id IN :ProspectSet]
            );
            list<i360__Prospect__c> ProspectsToUpdate = new list<i360__Prospect__c>();
            for(i360__Appointment__c Appointment : Trigger.new){
                i360__Prospect__c prospect = new i360__Prospect__c();
                Prospect.Id = ProspectMap.get(Appointment.i360__Prospect__c).Id;
                if(Appointment.i360__Quoted_Amount__c != NULL && Appointment.i360__Prospect__c != null){
                    prospect.Appointment_Quoted_Price__c = Appointment.i360__Quoted_Amount__c;
                }else{
                    prospect.Appointment_Quoted_Price__c = 0.00;
                }
                ProspectsToUpdate.add(prospect);
            }
            if(ProspectsToUpdate.size() > 0){
                update ProspectsToUpdate;
            }
        }
    }
}


 
Hello,

We are getting this error:
i360:Too many SOQL queries: 101 Error is in expression '{!Save}' in page i360:quickaction: (i360)    An unexpected error has occurred. Your solution provider has been notified. (i360)

From what we believe is the code below. Can you help us "clean up" the code and also let us know how to find the culprit of the error.
trigger Appointment_Price_Quoted on i360__Appointment__c (after update) 
{
    if(Trigger.isAfter)
    {
        if(Trigger.isupdate)
        {
            set<Id> ProspectSet = new set<Id>();
            for(i360__Appointment__c Appointment :Trigger.new){
                ProspectSet.add(Appointment.i360__Prospect__c);
            }
            map<string, i360__Prospect__c> ProspectMap = new map<string, i360__Prospect__c>(
               [SELECT Id, Appointment_Quoted_Price__c 
               FROM i360__Prospect__c
                WHERE Id IN :ProspectSet]
            );
            list<i360__Prospect__c> ProspectsToUpdate = new list<i360__Prospect__c>();
            for(i360__Appointment__c Appointment : Trigger.new){
                i360__Prospect__c prospect = new i360__Prospect__c();
                Prospect.Id = ProspectMap.get(Appointment.i360__Prospect__c).Id;
                if(Appointment.i360__Quoted_Amount__c != NULL && Appointment.i360__Prospect__c != null){
                    prospect.Appointment_Quoted_Price__c = Appointment.i360__Quoted_Amount__c;
                }else{
                    prospect.Appointment_Quoted_Price__c = 0.00;
                }
                ProspectsToUpdate.add(prospect);
            }
            if(ProspectsToUpdate.size() > 0){
                update ProspectMap.values();
            }
        }
    }
}
Hello, I have the Apex Trigger below that is updating the Else statement on the parent object (Prospect) as soon as the child record (Appointment) is created. I need the parent field (Appointment_Quoted_Price__c) to update when the IF statement is true. Your feedback is greatly appreciated.
trigger Appointment_Price_Quoted on i360__Appointment__c (after insert) 
{
    if(Trigger.isAfter)
    {
        if(Trigger.isInsert)
        {
            set<Id> ProspectSet = new set<Id>();
            for(i360__Appointment__c Appointment :Trigger.new){
                ProspectSet.add(Appointment.i360__Prospect__c);
            }
            map<string, i360__Prospect__c> ProspectMap = new map<string, i360__Prospect__c>(
               [SELECT Id, Appointment_Quoted_Price__c 
               FROM i360__Prospect__c
                WHERE Id IN :ProspectSet]
            );
            list<i360__Prospect__c> ProspectsToUpdate = new list<i360__Prospect__c>();
            for(i360__Appointment__c Appointment : Trigger.new){
                i360__Prospect__c prospect = new i360__Prospect__c();
                Prospect.Id = ProspectMap.get(Appointment.i360__Prospect__c).Id;
                if((Appointment.i360__Result__c == 'Demoed, Not Sold' || Appointment.i360__Result__c == 'Sold') &&  Appointment.i360__Prospect__c != null){
                    prospect.Appointment_Quoted_Price__c = Appointment.Quoted_Amount__c;
                }else{
                    prospect.Appointment_Quoted_Price__c = 0.00;
                }
                ProspectsToUpdate.add(prospect);
            }
            if(ProspectsToUpdate.size() > 0){
                update ProspectsToUpdate;
            }
        }
    }
}

 
Hello,

I have the trigger below that is NOT giving me any errors but it is not working. I need to update field Prospect.Demo_Not_Sold_Date__c with Appointment.i360__Result__c IF Appointment.i360__Result__c == 'Demoed, Not Sold'
trigger Appointment_DNS_Date on i360__Appointment__c (after insert) 
{
    if(Trigger.isAfter)
    {
        if(Trigger.isInsert)
        {
            set<Id> ProspectSet = new set<Id>();
            for(i360__Appointment__c Appointment :Trigger.new){
                ProspectSet.add(Appointment.i360__Prospect__c);
            }
            map<string, i360__Prospect__c> ProspectMap = new map<string, i360__Prospect__c>(
                [SELECT Id, Demo_Not_Sold_Date__c FROM i360__Prospect__c WHERE Id IN :ProspectSet]
            );
            list<i360__Prospect__c> ProspectsToUpdate = new list<i360__Prospect__c>();
            for(i360__Appointment__c appointment : Trigger.new){
                i360__Prospect__c prospect = new i360__Prospect__c();
                Prospect.Id = ProspectMap.get(Appointment.i360__Prospect__c).Id;
                if(Appointment.i360__Result__c == 'Demoed, Not Sold'){
                    prospect.Demo_Not_Sold_Date__c = appointment.Result_Date__c;
               
                }
                ProspectsToUpdate.add(prospect);
            }
            if(ProspectsToUpdate.size() > 0){
                update ProspectsToUpdate;
            }
        }
    }
}

 
Hello, I have a custom date field formula that will calculate when the sales commission should be paid next month.

If the customer pays between the 1st and the 15th of this month, the Sales Rep will receive their commission on the 1st of next month.
If the customer pays between the 16th and the 31st of this month, the Sales Rep will receive their commission on the 15th of next month.

The problem is that I need this field for each product which means that I have to create the field mutiple times. I gather this field and other fields for a Page View Report. Salesforce gives me this error when I create more than 5 of these formula fields:

Query is either selecting too many fields or the filter conditions are too complicated. 
An unexpected error has occurred. Your solution provider has been notified. (i360)


I was wondering if I can create an Apex Trigger for these formulas? The one below is for the product blinds.

PAGE VIEW REPORT FIELD:
IF(NOT(CE4B__c = 0.0) && (B1C__c = TRUE), 
"Amount: " & "$" & Text (CE4B__c) & BR() & 
"Owed On: " & Text (Blinds_Commissions_Owed_On__c) , "")

Object Name: i360__Sale__c
Field Name: Blinds 1st Check
API Name: B1C__c
Formula: IF(DAY(Costco_Paid_On_Blinds__c) <= 15,TRUE,FALSE)

Object Name: i360__Sale__c
Field Name: Blinds Commissions Owed On
API Name: Blinds_Commissions_Owed_On__c
Formula: IF (DAY ( Costco_Paid_On_Blinds__c) <= 15, BCOO1__c,BCOO15__c)

Object Name: i360__Sale__c
Field Name: Blinds Commissions Owed on the 1st
API Name: BCOO1__c
Formula: IF(DAY(Costco_Paid_On_Blinds__c) <= 15, 
DATE(YEAR(Costco_Paid_On_Blinds__c), MONTH(Costco_Paid_On_Blinds__c) + 1,01), 
DATE(YEAR(Costco_Paid_On_Blinds__c) + 1,MONTH(Costco_Paid_On_Blinds__c) - 10,01))

Object Name: i360__Sale__c
Field Name: Blinds Commissions Owed on the 15th
API Name: BCOO15__c
Formula: IF(DAY(Costco_Paid_On_Blinds__c) >= 16, 
DATE(YEAR(Costco_Paid_On_Blinds__c),MONTH(Costco_Paid_On_Blinds__c) + 1,15), 
DATE(YEAR(Costco_Paid_On_Blinds__c) + 1,MONTH(Costco_Paid_On_Blinds__c) - 10,01))

 
I need help on creating an apex trigger that maps one custom object currency field to another custom object currency field.

IF  (ObjectA.CustomFieldA != NULL)
Then  (ObjectB.CustomFieldB = ObjectA.CustomFieldA)
Else (ObjectB.CustomFieldB = 0.00)
 
I need to create a test class for an apex trigger in order to upload it from sandbox to production. I need help creating the test class as I am failry new at Salesforce development. Here is the apex trigger:

trigger Appointment_Closed on i360__Appointment__c (before insert) {
List<ID> ProspectIds = New List<ID>();
    
   for(i360__Appointment__c o : Trigger.new){
    if(o.i360__Result__c == 'Sold' | o.i360__Prospect__c != null){
      ProspectIds.add(o.i360__Prospect__c);
    }
  }
   List<i360__Prospect__c> ProspectList = [SELECT id, Appointment_Closed__c FROM i360__Prospect__c WHERE id in :ProspectIds];
  for(integer i = 0 ; i < ProspectList.size(); i++){
      ProspectList[i].Appointment_Closed__c = 1;
  
  }
  update ProspectList;
}
Hello,

I need help changing the code below to update Map Values. The code below creates a new instance of the prospect at line 18 and adds it to our prospect list which is causing this error:

i360.ProspectTriggers: execution of AfterUpdate caused by: System.DmlException: Update failed. First exception on row 0 with id a0416000010g4SdAAI; first error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, Appointment_Price_Quoted: execution of AfterUpdate caused by: System.ListException: Duplicate id in list: a0Z1600000AQwFjEAL Trigger.Appointment_Price_Quoted: line 28, column 1: [] Class.i360.ProspectUtilities.UpdateProspectNames: line 1509, column 1 Class.i360.Prospect_Trigger_Utilities.ProspectChangeName: line 175, column 1 Trigger.i360.ProspectTriggers: line 22, column 1
trigger Appointment_Price_Quoted on i360__Appointment__c (after update) 
{
    if(Trigger.isAfter)
    {
        if(Trigger.isupdate)
        {
            set<Id> ProspectSet = new set<Id>();
            for(i360__Appointment__c Appointment :Trigger.new){
                ProspectSet.add(Appointment.i360__Prospect__c);
            }
            map<string, i360__Prospect__c> ProspectMap = new map<string, i360__Prospect__c>(
               [SELECT Id, Appointment_Quoted_Price__c 
               FROM i360__Prospect__c
                WHERE Id IN :ProspectSet]
            );
            list<i360__Prospect__c> ProspectsToUpdate = new list<i360__Prospect__c>();
            for(i360__Appointment__c Appointment : Trigger.new){
                i360__Prospect__c prospect = new i360__Prospect__c();
                Prospect.Id = ProspectMap.get(Appointment.i360__Prospect__c).Id;
                if(Appointment.i360__Quoted_Amount__c != NULL && Appointment.i360__Prospect__c != null){
                    prospect.Appointment_Quoted_Price__c = Appointment.i360__Quoted_Amount__c;
                }else{
                    prospect.Appointment_Quoted_Price__c = 0.00;
                }
                ProspectsToUpdate.add(prospect);
            }
            if(ProspectsToUpdate.size() > 0){
                update ProspectsToUpdate;
            }
        }
    }
}


 
Hello,

We are getting this error:
i360:Too many SOQL queries: 101 Error is in expression '{!Save}' in page i360:quickaction: (i360)    An unexpected error has occurred. Your solution provider has been notified. (i360)

From what we believe is the code below. Can you help us "clean up" the code and also let us know how to find the culprit of the error.
trigger Appointment_Price_Quoted on i360__Appointment__c (after update) 
{
    if(Trigger.isAfter)
    {
        if(Trigger.isupdate)
        {
            set<Id> ProspectSet = new set<Id>();
            for(i360__Appointment__c Appointment :Trigger.new){
                ProspectSet.add(Appointment.i360__Prospect__c);
            }
            map<string, i360__Prospect__c> ProspectMap = new map<string, i360__Prospect__c>(
               [SELECT Id, Appointment_Quoted_Price__c 
               FROM i360__Prospect__c
                WHERE Id IN :ProspectSet]
            );
            list<i360__Prospect__c> ProspectsToUpdate = new list<i360__Prospect__c>();
            for(i360__Appointment__c Appointment : Trigger.new){
                i360__Prospect__c prospect = new i360__Prospect__c();
                Prospect.Id = ProspectMap.get(Appointment.i360__Prospect__c).Id;
                if(Appointment.i360__Quoted_Amount__c != NULL && Appointment.i360__Prospect__c != null){
                    prospect.Appointment_Quoted_Price__c = Appointment.i360__Quoted_Amount__c;
                }else{
                    prospect.Appointment_Quoted_Price__c = 0.00;
                }
                ProspectsToUpdate.add(prospect);
            }
            if(ProspectsToUpdate.size() > 0){
                update ProspectMap.values();
            }
        }
    }
}
I need help on creating an apex trigger that maps one custom object currency field to another custom object currency field.

IF  (ObjectA.CustomFieldA != NULL)
Then  (ObjectB.CustomFieldB = ObjectA.CustomFieldA)
Else (ObjectB.CustomFieldB = 0.00)
 
I need to create a test class for an apex trigger in order to upload it from sandbox to production. I need help creating the test class as I am failry new at Salesforce development. Here is the apex trigger:

trigger Appointment_Closed on i360__Appointment__c (before insert) {
List<ID> ProspectIds = New List<ID>();
    
   for(i360__Appointment__c o : Trigger.new){
    if(o.i360__Result__c == 'Sold' | o.i360__Prospect__c != null){
      ProspectIds.add(o.i360__Prospect__c);
    }
  }
   List<i360__Prospect__c> ProspectList = [SELECT id, Appointment_Closed__c FROM i360__Prospect__c WHERE id in :ProspectIds];
  for(integer i = 0 ; i < ProspectList.size(); i++){
      ProspectList[i].Appointment_Closed__c = 1;
  
  }
  update ProspectList;
}