• 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();
            }
        }
    }
}
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;
}