1

Following Salesforce docs, I createad a class that assignes milestones to cases. If the account has an entitlment, then it creates milestones. The class works super!.

The problem is the unitTest class this is the structure:

  1. Account created, then 'Insert' of accounts;
  2. Contact created and linked to Accounts, then 'Insert contacts' and 'Update Accounts'
  3. Entitlements created, SLAProcessid assigned (Yes the Process is Active), StartDate and EndDate assigned as well as business hours and accountId;(see code snippet below). Then 'Insert entitlements' and 'update accounts';

If you look at the screenshot the e.status is 'null' and I cannot figure out why. Any help? Thank you, GC

DebugLogs

for (Account acc : accounts) {
    Entitlement accountEntitlment = new Entitlement();
    accountEntitlment.AccountId = acc.Id;
    accountEntitlment.Account = acc;
    accountEntitlment.SlaProcessId = slaProcessesId[0].Id;
    accountEntitlment.Name = 'TestSLA ' + acc.Name;
    accountEntitlment.StartDate = Date.newInstance(2022, 1, 1);
    accountEntitlment.EndDate = Date.newInstance(2041, 4, 12);
    accountEntitlment.BusinessHours = businesshoursId;
    accountEntitlment.BusinessHoursId = businesshoursId.Id;
    accountEntitlments.add(accountEntitlment);
}

insert accountEntitlments;
update accounts;

System.debug('GC*** Created ENTITLEMENTS ' + accountEntitlments);
for (Entitlement e : accountEntitlments) {
    System.debug('GC*** Entitlement active? ' + e.Status);
    System.debug(
        'GC*** Entitlement process: ' +
        e.SlaProcessId +
        '\n' +
        'Start: ' +
        e.StartDate +
        '\n END DATE ' +
        e.EndDate +
        '\n Account: ' +
        e.Account.Name
    );
}

0

You must log in to answer this question.

Browse other questions tagged .