• gbrown
  • NEWBIE
  • 10 Points
  • Member since 2013
  • Founder
  • Appluent Business Solutions

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 4
    Questions
  • 15
    Replies

I created a trigger to insert and a new Ticket (custom object) whenever a new Case has been created and updates a Ticket when a Case has been updated.  The problem I am having is that my trigger is creating duplicates when a new Case is created.  How can I prevent the duplicate record from being created?  

I have searched high and low and have tried a couple of solutions including the cookbook recipe Preventing Duplicate Records from Saving but I have not been successful implementing the code in my current trigger.  

 

Tickets has a Master Detail field Case__c to Cases.

 

My code is as follows:

trigger createTicket2 on Case (after insert, before update) {
  
    //create new case if it does not exist
    for(Case c : Trigger.new){
        Tickets__c tik = new Tickets__c(
            case__c = c.id,
            subject__c = c.subject,
            origin__c = c.Origin,
            type__c = c.Type,
            Case_Record__c = c.Record_Type_Umbrella__c,
            new_problem__c = c.New_Problem__c,
            problem_area__c = c.problem_area__c,
            SAP_Return_Order_Number__c = c.SAP_Return_Order_Number__c);
        insert tik;
        
   List<Case> openCases = [SELECT c.subject, c.origin, c.problem_area__c, c.sap_return_order_number__c , c.LastModifiedDate, c.createddate  FROM Case c
  WHERE (c.Type ='Out of Box Failure') 
  FOR UPDATE];
  
           if(trigger.isupdate)
      {
      for(Case c1 : openCases)
   {   list<Tickets__c> t= [select id, subject__c from tickets__c where case__c=: c1.id ];
 // if (c1.LastModifiedDate != null && c1.LastModifiedDate > c1.CreatedDate)
        {
   //     c1.subject=t.subject__c;
   
      for (tickets__c t1: t )
{       if(shouldIRun.canIRun()==false )
         FutureGroup.FutureMethod(c1.id, t1.id);
         
         }
    }
  }
 
  }
 
       
            }
}

 Thanks,

 

  • November 13, 2013
  • Like
  • 0

I've created a simple trigger that will fire whenever a new case is created.  The trigger intent is to send case data to a custom object "Tickets".


I'm receiving an error on 5 - Unexpected Token: 'for'

 

Any ideas with what I'm doing wrong?

 

Thanks,

Greg

 

trigger createTicket on Case (after insert) {

    List <Ticket__c> tikToInsert = new List <Ticket__c> 
	
        for (Case c:Trigger.new) {
			//check if Case that is being inserted meets the criteria
            
		if (c.Type = "RMA") {  
            
            Ticket__c t = new Ticket__c (); 
            
           
            
            t.SAP_Return_Order__c = c.SAP_Return_Order__c; // map case fields to new ticket object that is being created with this case
            t.Subject__c = c.Subject; 
            
           	tikToInsert.add(t);
		
		
		}
		
	}
}

 

  • October 25, 2013
  • Like
  • 0

I am receiving this error on a custom object that is preventing the validation from passing.

 

Any ideas what could be done to fix this?

 

 

Type - Custom Object Definition

Problem - CancelEdit is not a standard action and cannot be overridden.

 

  • September 09, 2013
  • Like
  • 0

I'm having a difficult time to get my code coverage increased (I'm still a newb on the dev end).

My class is working and the test class passes, but I'm not able to piece it all together.  Any help?

 

My Class to display values on a VF page...

public class ascSummary{

    public ascSummary() {

    }


    public ascSummary(ApexPages.StandardController controller) {

    }


        public Visit__c getVisit()
    {
        
        //Retrieve Audit Results based on Id parameter of this page
        return [Select Id,
                Visit__c.Account__c,
                Visit__c.Contact__c,
                Visit__c.Visit_Date__c,
                Visit__c.Pre_audit_score__c,
                Visit__c.Workshop_Score1__c,
                Visit__c.Total_3_0v2__c,
                Visit__c.Total_4_0v2__c,
                Visit__c.Total_5_0v2__c,
                Visit__c.X1_0__c,
                Visit__c.X2_0__c,
                Visit__c.X3_0__c,
                Visit__c.X4_0__c,
                Visit__c.X5_0__c,
                Visit__c.Total_Percent__c,
                Visit__c.Total_Audit_Score__c
                from Visit__c j
                where Id = 
:ApexPages.currentPage().getParameters().get('id') ];
    }
}

 My test class..

@isTest
private class ascSummaryTestClass {
     static testMethod void validateascSummary() {
         visit__c v = new visit__c (Account__c='001c000000Qm4kp', Contact__c = '003c000000N7Bl0');
         insert v;
        
          // Retrieve the contact from the visit
        v = [SELECT Contact__c FROM Visit__c WHERE Id =:v.Id];
    System.debug('Contact after visit created: ' + v.Contact__c);  
    }
}

 

 

  • September 04, 2013
  • Like
  • 0

I created a trigger to insert and a new Ticket (custom object) whenever a new Case has been created and updates a Ticket when a Case has been updated.  The problem I am having is that my trigger is creating duplicates when a new Case is created.  How can I prevent the duplicate record from being created?  

I have searched high and low and have tried a couple of solutions including the cookbook recipe Preventing Duplicate Records from Saving but I have not been successful implementing the code in my current trigger.  

 

Tickets has a Master Detail field Case__c to Cases.

 

My code is as follows:

trigger createTicket2 on Case (after insert, before update) {
  
    //create new case if it does not exist
    for(Case c : Trigger.new){
        Tickets__c tik = new Tickets__c(
            case__c = c.id,
            subject__c = c.subject,
            origin__c = c.Origin,
            type__c = c.Type,
            Case_Record__c = c.Record_Type_Umbrella__c,
            new_problem__c = c.New_Problem__c,
            problem_area__c = c.problem_area__c,
            SAP_Return_Order_Number__c = c.SAP_Return_Order_Number__c);
        insert tik;
        
   List<Case> openCases = [SELECT c.subject, c.origin, c.problem_area__c, c.sap_return_order_number__c , c.LastModifiedDate, c.createddate  FROM Case c
  WHERE (c.Type ='Out of Box Failure') 
  FOR UPDATE];
  
           if(trigger.isupdate)
      {
      for(Case c1 : openCases)
   {   list<Tickets__c> t= [select id, subject__c from tickets__c where case__c=: c1.id ];
 // if (c1.LastModifiedDate != null && c1.LastModifiedDate > c1.CreatedDate)
        {
   //     c1.subject=t.subject__c;
   
      for (tickets__c t1: t )
{       if(shouldIRun.canIRun()==false )
         FutureGroup.FutureMethod(c1.id, t1.id);
         
         }
    }
  }
 
  }
 
       
            }
}

 Thanks,

 

  • November 13, 2013
  • Like
  • 0

Hi

 

 

I want to write a trigger for giving permissions only to 2 users based on the record type and channel in account , Please guide me how to do this.

 

 

Thanks

I've created a simple trigger that will fire whenever a new case is created.  The trigger intent is to send case data to a custom object "Tickets".


I'm receiving an error on 5 - Unexpected Token: 'for'

 

Any ideas with what I'm doing wrong?

 

Thanks,

Greg

 

trigger createTicket on Case (after insert) {

    List <Ticket__c> tikToInsert = new List <Ticket__c> 
	
        for (Case c:Trigger.new) {
			//check if Case that is being inserted meets the criteria
            
		if (c.Type = "RMA") {  
            
            Ticket__c t = new Ticket__c (); 
            
           
            
            t.SAP_Return_Order__c = c.SAP_Return_Order__c; // map case fields to new ticket object that is being created with this case
            t.Subject__c = c.Subject; 
            
           	tikToInsert.add(t);
		
		
		}
		
	}
}

 

  • October 25, 2013
  • Like
  • 0

Hi Team,

 

I have created a time dependent workflow rule. I have given time trigger as 1 hour after Created date.

 

I have created a four records satisfying the workflow rule criteria.

 

After half and hour of created date, i have changed the records for not satisfying the workflow rule criteria.

 

Now is actions will be applicable for all the four records or the records that are satifying the condition.

 

Thanks,

Anil

I am receiving this error on a custom object that is preventing the validation from passing.

 

Any ideas what could be done to fix this?

 

 

Type - Custom Object Definition

Problem - CancelEdit is not a standard action and cannot be overridden.

 

  • September 09, 2013
  • Like
  • 0

I'm having a difficult time to get my code coverage increased (I'm still a newb on the dev end).

My class is working and the test class passes, but I'm not able to piece it all together.  Any help?

 

My Class to display values on a VF page...

public class ascSummary{

    public ascSummary() {

    }


    public ascSummary(ApexPages.StandardController controller) {

    }


        public Visit__c getVisit()
    {
        
        //Retrieve Audit Results based on Id parameter of this page
        return [Select Id,
                Visit__c.Account__c,
                Visit__c.Contact__c,
                Visit__c.Visit_Date__c,
                Visit__c.Pre_audit_score__c,
                Visit__c.Workshop_Score1__c,
                Visit__c.Total_3_0v2__c,
                Visit__c.Total_4_0v2__c,
                Visit__c.Total_5_0v2__c,
                Visit__c.X1_0__c,
                Visit__c.X2_0__c,
                Visit__c.X3_0__c,
                Visit__c.X4_0__c,
                Visit__c.X5_0__c,
                Visit__c.Total_Percent__c,
                Visit__c.Total_Audit_Score__c
                from Visit__c j
                where Id = 
:ApexPages.currentPage().getParameters().get('id') ];
    }
}

 My test class..

@isTest
private class ascSummaryTestClass {
     static testMethod void validateascSummary() {
         visit__c v = new visit__c (Account__c='001c000000Qm4kp', Contact__c = '003c000000N7Bl0');
         insert v;
        
          // Retrieve the contact from the visit
        v = [SELECT Contact__c FROM Visit__c WHERE Id =:v.Id];
    System.debug('Contact after visit created: ' + v.Contact__c);  
    }
}

 

 

  • September 04, 2013
  • Like
  • 0

Hi Their is any way add hover text for standard object address field.

  • September 04, 2013
  • Like
  • 0