• VAHB
  • NEWBIE
  • 0 Points
  • Member since 2012

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 6
    Questions
  • 7
    Replies

Quick question on normal practice,

 

If you create test classes in the sandbox, separate test classes, do you Deploy those into production along with the actual code you want to deploy or u just leave that in the sandbox?

  • September 21, 2012
  • Like
  • 0

I currently have this written which isn't working out because sometimes people reopen cases

trigger UpdateResoTCategor on Case (before update) {

  Double timeStat;
  BusinessHours bh = [select id from businesshours where isDefault = true];
  
  for (Case c : Trigger.new){
    Case oldCase = Trigger.oldMap.get(c.ID);
      
      if (oldCase.Status != 'Closed' && (c.Status == 'Closed' || c.Status == 'Escalated')){
        timeStat = BusinessHours.diff(bh.id, c.CreatedDate, System.now())/3600000.0;
           
        c.TimeBetweenCase__c = timeStat;    
      }    
  }
}

 I want to calculate the time difference between open and closed in BusinessHouses based on CreatedDateTime and ClosedDateTime but the problem is that isClosed and the ClosedDate don't actually get genereated til afterwards. I tried to do the same thing on after update and used the ClosedDate field but I keep getting errors on it: "execution of AfterUpdate caused by: System.FinalException: Record is read-only"

 

Does anyone have any ideas on how to do this?

 

  • August 10, 2012
  • Like
  • 0

I want to write a trigger that categorizes based on the number of business days that have surpassed.

Right now I have a formula field (number) that calculates business days as long as the case isn't closed, this formula updates daily on business days incrementing one per day, however the trigger should also update as the formula updates.

 

Is this possible?

 

Thanks

  • August 02, 2012
  • Like
  • 0

I am trying to figure out how to edit an object after update.

I dont really care if it is before or after, but I need to use the ClosedDate field after the Status = Closed. If I use before update the status of the new object is Closed but the ClosedDate hasn't been generated (I'm guessing because it hasn't been inserted yet so Salesforce hasn't filled in the date yet.

 

What would the best way to go about doing this, using the newMap field and editing? I get some read only errors when I do this.

 

ANy help is appreciated

  • August 01, 2012
  • Like
  • 0

I am creating a test case on a Trigger that acts on Cases Object

 

I am creating an object

Case abc = new Case ();

 

when I do system.debug ('The case created date is: ' + abc.CreatedDate);

 

In the output I see null for the created data, isn't this automatically generated how can it be null? its a not writable field

  • July 20, 2012
  • Like
  • 0

Hey I am a complete beginner in this, I am sure I am making a stupid mistake but I wanted to set a field in Case Object based on two other fields. I am attempted to run it in Developer COnside and getting error: line 1, column 0: required (...)+ loop did not match anything at input 'trigger'

 

It fills in the value of the Closed By when a case is closed. It sets it to Sent To if it is not null, if not a case is always created by someone so it sets it to that value


 

trigger closedByTest on Case (before update) {    
        for (Case c : Trigger.new){
            Case oldcase = Trigger.oldMap.get(c.ID);

            if (c.ClosedDate != oldcase.ClosedDate){
                if (c.Sent_To__c != null)
                    c.Closed_By__c = c.Sent_To__c;
                else
                    c.Closed_By__c = c.OwnerId;
            }
            else {}
        }
}

  • July 20, 2012
  • Like
  • 0

I currently have this written which isn't working out because sometimes people reopen cases

trigger UpdateResoTCategor on Case (before update) {

  Double timeStat;
  BusinessHours bh = [select id from businesshours where isDefault = true];
  
  for (Case c : Trigger.new){
    Case oldCase = Trigger.oldMap.get(c.ID);
      
      if (oldCase.Status != 'Closed' && (c.Status == 'Closed' || c.Status == 'Escalated')){
        timeStat = BusinessHours.diff(bh.id, c.CreatedDate, System.now())/3600000.0;
           
        c.TimeBetweenCase__c = timeStat;    
      }    
  }
}

 I want to calculate the time difference between open and closed in BusinessHouses based on CreatedDateTime and ClosedDateTime but the problem is that isClosed and the ClosedDate don't actually get genereated til afterwards. I tried to do the same thing on after update and used the ClosedDate field but I keep getting errors on it: "execution of AfterUpdate caused by: System.FinalException: Record is read-only"

 

Does anyone have any ideas on how to do this?

 

  • August 10, 2012
  • Like
  • 0

I am trying to figure out how to edit an object after update.

I dont really care if it is before or after, but I need to use the ClosedDate field after the Status = Closed. If I use before update the status of the new object is Closed but the ClosedDate hasn't been generated (I'm guessing because it hasn't been inserted yet so Salesforce hasn't filled in the date yet.

 

What would the best way to go about doing this, using the newMap field and editing? I get some read only errors when I do this.

 

ANy help is appreciated

  • August 01, 2012
  • Like
  • 0

I am creating a test case on a Trigger that acts on Cases Object

 

I am creating an object

Case abc = new Case ();

 

when I do system.debug ('The case created date is: ' + abc.CreatedDate);

 

In the output I see null for the created data, isn't this automatically generated how can it be null? its a not writable field

  • July 20, 2012
  • Like
  • 0

I want to know whether a datetime is holiday through the setting of holiday?

 

thank you!