2

Is there any way we can query and get the Milestone name based on CaseMilestone object details ? I have a trigger and I want to dynamically pass the MileStone name value instead of doing hard-coding as shown below. Any pointers ?

public class CompleteMilesone {

    public static void completeMilestoneDate(List<SObject> newSobjs, Map<Id,SObject> oldSobjsMap){
        ...........
        ..........
        ..........
        ...........

        if(!caseIds1.isEmpty())
            MilestoneUtils.completeMilestone(caseIds1, 'ABC', System.now());
        else if(!caseIds2.isEmpty())
             MilestoneUtils.completeMilestone(caseIds2,'XYZ', System.now());
    }
}

I tried below query,

SELECT AssetId,CasesPerEntitlement,EndDate,Id,Name,Status,Type FROM Entitlement
1

To retrieve Milestone Name you need to execute this query

SELECT Id, Name FROM MilestoneType 
where Id IN 
(SELECT MilestoneTypeId 
FROM CaseMilestone 
WHERE CaseId = '<case id>')
1
  • Thanks, How you calculate such a nice query? This works fine
    – user46657
    Jul 18 '17 at 19:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy