• Chuck Harvey
  • NEWBIE
  • 10 Points
  • Member since 2014

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 5
    Questions
  • 8
    Replies
I tested my class in the sandbox environment and my trigger reported 94%.  But when I tried to move it to production, am geting an error.

StatusID.insertID(), Details: System.DmlException: Update failed. First exception on row 0; first error: MISSING_ARGUMENT, Id not specified in an update call: [] Class.StatusID.insertID: line 28, column 1 IandUStatusReport, Details: Test coverage of selected Apex Trigger is 0%, at least 1% test coverage is required

The insert works but the Update does not.  I thought the ID would be carried over to the update.

Class:  

@isTest
public class StatusID {
  static testmethod void insertID() {
  Date myDate = Date.today();
  // List<Customer_Fact_Sheet__c> listSTA = new List<Customer_Fact_Sheet__c>();
  // List <Customer_Fact_Sheet__c> cid = [Select Name, Project_c__c from Customer_Fact_Sheet__c   
  //where Name = 'A'];
  //insert data for insert and update status report
    Customer_Fact_Sheet__c cfs = new Customer_Fact_Sheet__c (Name = 'A',Project_c__c = 'a0kd000000ApbI3AA5',Criteria_Defect__c = 'No Defects Know'
       );
//    cfs.Name = 'A';
//    cfs.Project_c__c = 'a0kJ0000001tENQIA2';
//    cfs.Report_Date__c = myDate;
//    cfs.Criteria_Defect__c = 'No Defects Know';
//    cfs.Critical_Enhancements__c = 'Customer wants the Query Editor to run through all tables';
//    cfs.Next_Action__c = 'Testing is starting next week';
//    cfs.Current_Issues_or_Impedients__c = 'No current issues reported at this time';
//    cfs.Current_Services_Personnel_Involved__c = 'John Doe is on the project 75% of the time';
    
//     listSTA.add(cfs);
  try{
     insert (cfs);
  }
 catch (Exception e) {
      system.debug('Exception'+e);}
   //Update data  
     cfs.Criteria_Defect__c = 'N/A';
    update (cfs);     
   }
 }

Trigger:

trigger IandUStatusReport on Customer_Fact_Sheet__c   (after insert, after update)
{   
    List<Status_Report__c> listSTA = new List<Status_Report__c>();
    List<Status_Report__c> updsta = new List<Status_Report__c>();
    MAP <String, Customer_Fact_Sheet__c> objMap = new Map<String, Customer_Fact_Sheet__c>();
     for (Customer_Fact_Sheet__c cfs : Trigger.new){ 
       List<Status_Report__c > dupes =[ Select Status_Unique_ID__c, Name from  Status_Report__c 
       where Status_Unique_ID__c = :cfs.Status_Unique_ID__c LIMIT 1];
           if (dupes.size() == 0) { 
            Status_Report__c sta = new Status_Report__c();
          // Insert new Status record
            system.debug(cfs.Project_c__c);
            sta.Status_Unique_ID__c = cfs.Status_Unique_ID__c;
            sta.Project__c = cfs.Project_c__c;
            sta.Report_Date__c  = cfs.Report_Date__c;
            sta.Critical_Defects__c  = cfs.Criteria_Defect__c;
            sta.Critical_Enhancements__c  = cfs.Critical_Enhancements__c;
            sta.Next_Action__c  = cfs.Next_Action__c;
            sta.Current_Issues_or_Impediments__c  = cfs.Current_Issues_or_Impedients__c;
            sta.Services_Personnel_Involved__c  = cfs.Current_Services_Personnel_Involved__c;

           listSTA.add(sta);
  try{
     insert listSTA;
  }
 catch (Exception e) {
      system.debug('Exception'+e);
   }
         
   }
       
     
       
       for(Status_Report__c sr: dupes)
       {
          Customer_Fact_Sheet__c cfs1 = objMap.get(sr.Status_Unique_ID__c);
          // Update new Status record
            system.debug(sr.Status_Unique_ID__c);
            sr.Status_Unique_ID__c = cfs.Status_Unique_ID__c;
            sr.Report_Date__c  = cfs.Report_Date__c;
            sr.Critical_Defects__c  = cfs.Criteria_Defect__c;
            sr.Critical_Enhancements__c  = cfs.Critical_Enhancements__c;
            sr.Next_Action__c  = cfs.Next_Action__c;
            sr.Current_Issues_or_Impediments__c  = cfs.Current_Issues_or_Impedients__c;
            sr.Services_Personnel_Involved__c  = cfs.Current_Services_Personnel_Involved__c;

          updsta.add(sr);}  
  if(updsta.size() > 0){ 
  try{
     update updsta;
  }
 catch (Exception e) {
      system.debug('Exception'+e);} }}

}
 
I am trying to write a simple trigger and class to sum a column in multiple records and dispaly the results in Projects.

The trigger is designed to sum column (Total_Invoice_Amount__c(custom field)) in Time Records and display the results in column  Actual_Pre_Payment_Amount__c in Projects.

It runs but no results.

Trigger:

trigger PrePaidAmount on Milestone1_Project__c (after insert, after update) {
    List< Milestone1_Project__c > listTiv = new List< Milestone1_Project__c >();
   
     for (Milestone1_Project__c mp : Trigger.new){ 
       List<AggregateResult> dupes =[ Select Project1__c, sum(Total_Invoice_Amount__c) tiv  from  Time_Record__c
       where Project1__c = :mp.Name Group by Project1__c];
       for(AggregateResult ar : dupes){
 Integer SumAmount = (Integer) ar.get('tiv');
           if (dupes.size() > 0) { 
            Milestone1_Project__c pro = new Milestone1_Project__c ();
          // Insert new Pre-Payment into Projects record
            system.debug(mp.NAME);
            pro.Actual_Pre_Payment_Amount__c = SumAmount;
           listTiv.add(pro);}
  try{
     insert listTiv;
  }
 catch (Exception e) {
      system.debug('Exception'+e);
   }
   }
}}
I am trying to create a trigger that will take information from one customer object (Customer_Fact_Sheet__c) and insert or update into another object (Status_Report__c).   The insert part of the trigger is working properly but the Update statement is giving me an exception.  

The error message is: System.DmlException: Update failed. First exception on row 0; first error: MISING_AGRUEMENT, Id not specified in an update call:[].

I have checked to make sure there is a record is in the Status_Report__c table to update and there is only one record in Status_Report__c object with the same Status_Report_ID.



trigger InsandUpdStatusReport on Customer_Fact_Sheet__c   (after insert, after update)

    list<Status_Report__c> listSTA = new List<Status_Report__c>();
     for (Customer_Fact_Sheet__c cfs : Trigger.new){ 
       List<Status_Report__c > dupes =[ Select Status_Unique_ID__c from  Status_Report__c 
       where Status_Unique_ID__c = :cfs.Status_Unique_ID__c];
           if (dupes.size() != null) { 
            Status_Report__c sta = new Status_Report__c();
          // Insert new Status record
            system.debug(cfs.Project_c__c);
            sta.Status_Unique_ID__c = cfs.Status_Unique_ID__c;
            sta.Project__c = cfs.Project_c__c;
            sta.Report_Date__c  = cfs.Report_Date__c;
            sta.Critical_Defects__c  = cfs.Criteria_Defect__c;
            sta.Critical_Enhancements__c  = cfs.Critical_Enhancements__c;
            sta.Next_Action__c  = cfs.Next_Action__c;
            sta.Current_Issues_or_Impediments__c  = cfs.Current_Issues_or_Impedients__c;
            sta.Services_Personnel_Involved__c  = cfs.Current_Services_Personnel_Involved__c;

           listSTA.add(sta);
  try{
     insert listSTA;
  }
 catch (Exception e) {
      system.debug('Exception'+e);
   }
         
   }
       else
       { Status_Report__c updsta = new Status_Report__c(Status_Unique_ID__c = dupes[0].Status_Unique_ID__c );
           
          // Update new Status record
            system.debug(dupes[0].Status_Unique_ID__c);
            updsta.Project__c = cfs.Project_c__c;
            updsta.Report_Date__c  = cfs.Report_Date__c;
            updsta.Critical_Defects__c  = cfs.Criteria_Defect__c;
            updsta.Critical_Enhancements__c  = cfs.Critical_Enhancements__c;
            updsta.Next_Action__c  = cfs.Next_Action__c;
            updsta.Current_Issues_or_Impediments__c  = cfs.Current_Issues_or_Impedients__c;
            updsta.Services_Personnel_Involved__c  = cfs.Current_Services_Personnel_Involved__c;

          listSTA.add(updsta);}
    }
try{
     update listSTA;
  }
 catch (Exception e) {
      system.debug('Exception'+e);
   }
}
The trigger I created is saving and running but it does not create  a new record.  I am putting information in a custom object called Customer Fact Sheet and moving the data into Status Report.  In the developer console does not show problems.  Does anyone see a prolem with the trigger?

Customer_Fact_Sheet__c = Source object
Status_Report__c = Target object

trigger InsertStatusReport on Customer_Fact_Sheet__c  (after insert)
{  for (Customer_Fact_Sheet__c cfs : Trigger.new)
        String cid = cfs.
{try{    Status_Report__c sta = new Status_Report__c();
        // Insert new Status record
        system.debug(cfs.Project_c__c);
        sta.Status_Unique_ID__c = '12a';
        sta.Project__c = cfs.Project_c__c;
     insert sta;
   }
 catch (Exception e) {system.debug('Exception'+e);}
   }
}
 
I have a custom object I created called Customer Fact Sheet.  When I save in the Customer Fact Sheet, I want a new record to create in the Status Report object with the Status_Unique_ID the same as what is in CUstomer Fact Sheet.  I am trying to create a class that will create a new record and pass the Status Unique ID.  The Error I am getting is Status Unique ID column is not in the Status Report object.  I cannot figure out why because I am copying the API name from the Status Report object so it should be a match.  After I get these solved, I would like to see there is no duplicate before I insert.

@isTest
public class StatusID {
  static testmethod void insertID() {
   List<Customer_Fact_Sheet__c> result = [SELECT Status_Unique_ID__c  FROM Customer_Fact_Sheet__c
                WHERE Status_Unique_ID__c = :ApexPages.currentPage().getParameters().get(' Status_Unique_ID__c')];
 {       if (result.size() > 0) 
        Status_Report__c IStatus = new Status_Report__c();
        IStatus.Status_Unique_ID__c = result[0].Status_Unique_ID__c;
        insert IStatus;
         }     
     }
 }
Error: Compile Error: Variable does not exist:IStatus:Status_Unique_ID__c at line 8 column 9
I tested my class in the sandbox environment and my trigger reported 94%.  But when I tried to move it to production, am geting an error.

StatusID.insertID(), Details: System.DmlException: Update failed. First exception on row 0; first error: MISSING_ARGUMENT, Id not specified in an update call: [] Class.StatusID.insertID: line 28, column 1 IandUStatusReport, Details: Test coverage of selected Apex Trigger is 0%, at least 1% test coverage is required

The insert works but the Update does not.  I thought the ID would be carried over to the update.

Class:  

@isTest
public class StatusID {
  static testmethod void insertID() {
  Date myDate = Date.today();
  // List<Customer_Fact_Sheet__c> listSTA = new List<Customer_Fact_Sheet__c>();
  // List <Customer_Fact_Sheet__c> cid = [Select Name, Project_c__c from Customer_Fact_Sheet__c   
  //where Name = 'A'];
  //insert data for insert and update status report
    Customer_Fact_Sheet__c cfs = new Customer_Fact_Sheet__c (Name = 'A',Project_c__c = 'a0kd000000ApbI3AA5',Criteria_Defect__c = 'No Defects Know'
       );
//    cfs.Name = 'A';
//    cfs.Project_c__c = 'a0kJ0000001tENQIA2';
//    cfs.Report_Date__c = myDate;
//    cfs.Criteria_Defect__c = 'No Defects Know';
//    cfs.Critical_Enhancements__c = 'Customer wants the Query Editor to run through all tables';
//    cfs.Next_Action__c = 'Testing is starting next week';
//    cfs.Current_Issues_or_Impedients__c = 'No current issues reported at this time';
//    cfs.Current_Services_Personnel_Involved__c = 'John Doe is on the project 75% of the time';
    
//     listSTA.add(cfs);
  try{
     insert (cfs);
  }
 catch (Exception e) {
      system.debug('Exception'+e);}
   //Update data  
     cfs.Criteria_Defect__c = 'N/A';
    update (cfs);     
   }
 }

Trigger:

trigger IandUStatusReport on Customer_Fact_Sheet__c   (after insert, after update)
{   
    List<Status_Report__c> listSTA = new List<Status_Report__c>();
    List<Status_Report__c> updsta = new List<Status_Report__c>();
    MAP <String, Customer_Fact_Sheet__c> objMap = new Map<String, Customer_Fact_Sheet__c>();
     for (Customer_Fact_Sheet__c cfs : Trigger.new){ 
       List<Status_Report__c > dupes =[ Select Status_Unique_ID__c, Name from  Status_Report__c 
       where Status_Unique_ID__c = :cfs.Status_Unique_ID__c LIMIT 1];
           if (dupes.size() == 0) { 
            Status_Report__c sta = new Status_Report__c();
          // Insert new Status record
            system.debug(cfs.Project_c__c);
            sta.Status_Unique_ID__c = cfs.Status_Unique_ID__c;
            sta.Project__c = cfs.Project_c__c;
            sta.Report_Date__c  = cfs.Report_Date__c;
            sta.Critical_Defects__c  = cfs.Criteria_Defect__c;
            sta.Critical_Enhancements__c  = cfs.Critical_Enhancements__c;
            sta.Next_Action__c  = cfs.Next_Action__c;
            sta.Current_Issues_or_Impediments__c  = cfs.Current_Issues_or_Impedients__c;
            sta.Services_Personnel_Involved__c  = cfs.Current_Services_Personnel_Involved__c;

           listSTA.add(sta);
  try{
     insert listSTA;
  }
 catch (Exception e) {
      system.debug('Exception'+e);
   }
         
   }
       
     
       
       for(Status_Report__c sr: dupes)
       {
          Customer_Fact_Sheet__c cfs1 = objMap.get(sr.Status_Unique_ID__c);
          // Update new Status record
            system.debug(sr.Status_Unique_ID__c);
            sr.Status_Unique_ID__c = cfs.Status_Unique_ID__c;
            sr.Report_Date__c  = cfs.Report_Date__c;
            sr.Critical_Defects__c  = cfs.Criteria_Defect__c;
            sr.Critical_Enhancements__c  = cfs.Critical_Enhancements__c;
            sr.Next_Action__c  = cfs.Next_Action__c;
            sr.Current_Issues_or_Impediments__c  = cfs.Current_Issues_or_Impedients__c;
            sr.Services_Personnel_Involved__c  = cfs.Current_Services_Personnel_Involved__c;

          updsta.add(sr);}  
  if(updsta.size() > 0){ 
  try{
     update updsta;
  }
 catch (Exception e) {
      system.debug('Exception'+e);} }}

}
 
I am trying to create a trigger that will take information from one customer object (Customer_Fact_Sheet__c) and insert or update into another object (Status_Report__c).   The insert part of the trigger is working properly but the Update statement is giving me an exception.  

The error message is: System.DmlException: Update failed. First exception on row 0; first error: MISING_AGRUEMENT, Id not specified in an update call:[].

I have checked to make sure there is a record is in the Status_Report__c table to update and there is only one record in Status_Report__c object with the same Status_Report_ID.



trigger InsandUpdStatusReport on Customer_Fact_Sheet__c   (after insert, after update)

    list<Status_Report__c> listSTA = new List<Status_Report__c>();
     for (Customer_Fact_Sheet__c cfs : Trigger.new){ 
       List<Status_Report__c > dupes =[ Select Status_Unique_ID__c from  Status_Report__c 
       where Status_Unique_ID__c = :cfs.Status_Unique_ID__c];
           if (dupes.size() != null) { 
            Status_Report__c sta = new Status_Report__c();
          // Insert new Status record
            system.debug(cfs.Project_c__c);
            sta.Status_Unique_ID__c = cfs.Status_Unique_ID__c;
            sta.Project__c = cfs.Project_c__c;
            sta.Report_Date__c  = cfs.Report_Date__c;
            sta.Critical_Defects__c  = cfs.Criteria_Defect__c;
            sta.Critical_Enhancements__c  = cfs.Critical_Enhancements__c;
            sta.Next_Action__c  = cfs.Next_Action__c;
            sta.Current_Issues_or_Impediments__c  = cfs.Current_Issues_or_Impedients__c;
            sta.Services_Personnel_Involved__c  = cfs.Current_Services_Personnel_Involved__c;

           listSTA.add(sta);
  try{
     insert listSTA;
  }
 catch (Exception e) {
      system.debug('Exception'+e);
   }
         
   }
       else
       { Status_Report__c updsta = new Status_Report__c(Status_Unique_ID__c = dupes[0].Status_Unique_ID__c );
           
          // Update new Status record
            system.debug(dupes[0].Status_Unique_ID__c);
            updsta.Project__c = cfs.Project_c__c;
            updsta.Report_Date__c  = cfs.Report_Date__c;
            updsta.Critical_Defects__c  = cfs.Criteria_Defect__c;
            updsta.Critical_Enhancements__c  = cfs.Critical_Enhancements__c;
            updsta.Next_Action__c  = cfs.Next_Action__c;
            updsta.Current_Issues_or_Impediments__c  = cfs.Current_Issues_or_Impedients__c;
            updsta.Services_Personnel_Involved__c  = cfs.Current_Services_Personnel_Involved__c;

          listSTA.add(updsta);}
    }
try{
     update listSTA;
  }
 catch (Exception e) {
      system.debug('Exception'+e);
   }
}
The trigger I created is saving and running but it does not create  a new record.  I am putting information in a custom object called Customer Fact Sheet and moving the data into Status Report.  In the developer console does not show problems.  Does anyone see a prolem with the trigger?

Customer_Fact_Sheet__c = Source object
Status_Report__c = Target object

trigger InsertStatusReport on Customer_Fact_Sheet__c  (after insert)
{  for (Customer_Fact_Sheet__c cfs : Trigger.new)
        String cid = cfs.
{try{    Status_Report__c sta = new Status_Report__c();
        // Insert new Status record
        system.debug(cfs.Project_c__c);
        sta.Status_Unique_ID__c = '12a';
        sta.Project__c = cfs.Project_c__c;
     insert sta;
   }
 catch (Exception e) {system.debug('Exception'+e);}
   }
}
 
I have a custom object I created called Customer Fact Sheet.  When I save in the Customer Fact Sheet, I want a new record to create in the Status Report object with the Status_Unique_ID the same as what is in CUstomer Fact Sheet.  I am trying to create a class that will create a new record and pass the Status Unique ID.  The Error I am getting is Status Unique ID column is not in the Status Report object.  I cannot figure out why because I am copying the API name from the Status Report object so it should be a match.  After I get these solved, I would like to see there is no duplicate before I insert.

@isTest
public class StatusID {
  static testmethod void insertID() {
   List<Customer_Fact_Sheet__c> result = [SELECT Status_Unique_ID__c  FROM Customer_Fact_Sheet__c
                WHERE Status_Unique_ID__c = :ApexPages.currentPage().getParameters().get(' Status_Unique_ID__c')];
 {       if (result.size() > 0) 
        Status_Report__c IStatus = new Status_Report__c();
        IStatus.Status_Unique_ID__c = result[0].Status_Unique_ID__c;
        insert IStatus;
         }     
     }
 }
Error: Compile Error: Variable does not exist:IStatus:Status_Unique_ID__c at line 8 column 9