• j-dog
  • NEWBIE
  • 0 Points
  • Member since 2013

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 2
    Questions
  • 6
    Replies
Hello,

SFDC doesn't have allow updates to milestone completion date so they offered up some apex as a 'delivered' solution to an Idea (https://success.salesforce.com/ideaview?id=08730000000HS83AAG).  So, trying to follow their example, I modified it to match based on the conditions we use. We are trying to move to milestones.  However, currently, we use three date/time fields (Response, Restore, Resolve) and then we have three resulting fields that cacluate (open date/time - response time). Pretty basic.

So, the modified code, below, works well when I enter a response time, click save, enter a restore time, click save, and enter a resolve time and click save.  The completion data will be filled out for the correct milestone.  This is great.  However, there are times when a case can be responded to, restored, and resolved at the same time so the agent will populate each of those date/time fields and click save.  What happens in that situation is that the date/time for each of those fields is set, however, the resulting fields are blank (all it does is subtracked response time from create time, and restore time from create time, and resolve time from create time (6 fields in total (3 date/time, 3 resulting times).  When this happens, the milestones do not have the completion date filled out.  We can edit be clearing the date/time fields and entering them one at a time, saving each time.

I'm not sure why this is happening.  Any thoughts, advice?

trigger completeResponseMilestone on Case (after update) {
    // Cannot be a portal user
    String responseMilestoneName;
    if (UserInfo.getUserType() == 'Standard'){
        DateTime completionDate = System.now();
            List<Id> updateCases = new List<Id>();
            for (Case c : Trigger.new){
                // Response
                if (((c.Status != 'Closed')&&(c.Status != 'Closed as Duplicate'))&& (c.Severity__c == 'Severity 4 - Low')&&((c.SlaStartDate <= completionDate)&&(c.SlaExitDate == null) && (c.Response_Time__c != null)))
                    responseMilestoneName = 'Default Low Response';
                    updateCases.add(c.Id);
                if (((c.Status != 'Closed')&&(c.Status != 'Closed as Duplicate'))&& (c.Severity__c == 'Severity 3 - Minor')&&((c.SlaStartDate <= completionDate)&&(c.SlaExitDate == null) && (c.Response_Time__c != null)))
                    responseMilestoneName = 'Default Minor Response';
                    updateCases.add(c.Id);
                if (((c.Status != 'Closed')&&(c.Status != 'Closed as Duplicate'))&& (c.Severity__c == 'Severity 2 - Major')&&((c.SlaStartDate <= completionDate)&&(c.SlaExitDate == null) && (c.Response_Time__c != null)))
                    responseMilestoneName = 'Default Major Response';
                    updateCases.add(c.Id);
                if (((c.Status != 'Closed')&&(c.Status != 'Closed as Duplicate'))&& (c.Severity__c == 'Severity 1 - Critical')&&((c.SlaStartDate <= completionDate)&&(c.SlaExitDate == null) && (c.Response_Time__c != null)))
                    responseMilestoneName = 'Default Critical Response';
                    updateCases.add(c.Id);
        }
    if (updateCases.isEmpty() == false)
        milestoneUtils.completeMilestone(updateCases, responseMilestoneName, completionDate);
    }
}

It seems like the trigger is blocking is blocking something, but I don't know what, or how.  I've trimmed down the code just to focus on response time.  I would like to use the same code to also handle restore and resolve, just continue with the if statements and set restore/resolve variables.  It seemed to work, but when I ran into this issue, I thought maybe trying to manage all three fields was the issue.  But it doesn't seem to be.

Thanks for the help...
  • September 27, 2015
  • Like
  • 0

Testing this out, I'm an admin user, ower of an account, created case swarm rule for cases for accounts I own and added my boss, also an SFDC admin, create case, he is not added.  Create rule for All cases, my boss can be added.

 

Tried the same thing but added some sales guys to swarm.  None could swarm.

 

I don't understand why?  Is there any kind of set up document or document that says what all settings need to be to have full functionality of cloud swarm?

 

Yes - it's deployed.  

 

Thanks for any help.

 

j-dog

  • February 10, 2013
  • Like
  • 0
Hello,

SFDC doesn't have allow updates to milestone completion date so they offered up some apex as a 'delivered' solution to an Idea (https://success.salesforce.com/ideaview?id=08730000000HS83AAG).  So, trying to follow their example, I modified it to match based on the conditions we use. We are trying to move to milestones.  However, currently, we use three date/time fields (Response, Restore, Resolve) and then we have three resulting fields that cacluate (open date/time - response time). Pretty basic.

So, the modified code, below, works well when I enter a response time, click save, enter a restore time, click save, and enter a resolve time and click save.  The completion data will be filled out for the correct milestone.  This is great.  However, there are times when a case can be responded to, restored, and resolved at the same time so the agent will populate each of those date/time fields and click save.  What happens in that situation is that the date/time for each of those fields is set, however, the resulting fields are blank (all it does is subtracked response time from create time, and restore time from create time, and resolve time from create time (6 fields in total (3 date/time, 3 resulting times).  When this happens, the milestones do not have the completion date filled out.  We can edit be clearing the date/time fields and entering them one at a time, saving each time.

I'm not sure why this is happening.  Any thoughts, advice?

trigger completeResponseMilestone on Case (after update) {
    // Cannot be a portal user
    String responseMilestoneName;
    if (UserInfo.getUserType() == 'Standard'){
        DateTime completionDate = System.now();
            List<Id> updateCases = new List<Id>();
            for (Case c : Trigger.new){
                // Response
                if (((c.Status != 'Closed')&&(c.Status != 'Closed as Duplicate'))&& (c.Severity__c == 'Severity 4 - Low')&&((c.SlaStartDate <= completionDate)&&(c.SlaExitDate == null) && (c.Response_Time__c != null)))
                    responseMilestoneName = 'Default Low Response';
                    updateCases.add(c.Id);
                if (((c.Status != 'Closed')&&(c.Status != 'Closed as Duplicate'))&& (c.Severity__c == 'Severity 3 - Minor')&&((c.SlaStartDate <= completionDate)&&(c.SlaExitDate == null) && (c.Response_Time__c != null)))
                    responseMilestoneName = 'Default Minor Response';
                    updateCases.add(c.Id);
                if (((c.Status != 'Closed')&&(c.Status != 'Closed as Duplicate'))&& (c.Severity__c == 'Severity 2 - Major')&&((c.SlaStartDate <= completionDate)&&(c.SlaExitDate == null) && (c.Response_Time__c != null)))
                    responseMilestoneName = 'Default Major Response';
                    updateCases.add(c.Id);
                if (((c.Status != 'Closed')&&(c.Status != 'Closed as Duplicate'))&& (c.Severity__c == 'Severity 1 - Critical')&&((c.SlaStartDate <= completionDate)&&(c.SlaExitDate == null) && (c.Response_Time__c != null)))
                    responseMilestoneName = 'Default Critical Response';
                    updateCases.add(c.Id);
        }
    if (updateCases.isEmpty() == false)
        milestoneUtils.completeMilestone(updateCases, responseMilestoneName, completionDate);
    }
}

It seems like the trigger is blocking is blocking something, but I don't know what, or how.  I've trimmed down the code just to focus on response time.  I would like to use the same code to also handle restore and resolve, just continue with the if statements and set restore/resolve variables.  It seemed to work, but when I ran into this issue, I thought maybe trying to manage all three fields was the issue.  But it doesn't seem to be.

Thanks for the help...
  • September 27, 2015
  • Like
  • 0

Testing this out, I'm an admin user, ower of an account, created case swarm rule for cases for accounts I own and added my boss, also an SFDC admin, create case, he is not added.  Create rule for All cases, my boss can be added.

 

Tried the same thing but added some sales guys to swarm.  None could swarm.

 

I don't understand why?  Is there any kind of set up document or document that says what all settings need to be to have full functionality of cloud swarm?

 

Yes - it's deployed.  

 

Thanks for any help.

 

j-dog

  • February 10, 2013
  • Like
  • 0