web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

Apply an SLA to a case in a Plugin / SDK

(0) ShareShare
ReportReport
Posted on by 20

I have this scenario with SLA's where I want to apply the SLA to the case in the case creation plugin based on the contact's time zone.

So, I have setup 2 SLA's, one for EST and one for PST working hours.

Scenario 1:

Contact is in US Eastern Time Zone, so I want to apply the SLA with working hours from 8am - 5pm ET.

Scenario 2:

Contact is in US Pacific Time Zone, so I want to apply the SLA with working hours from 9am - 5pm PT

This is useful so that the customer in the ET gets paused at 5pm ET and starts again in the morning, and similarly for the customer in the PT.

I can see in the SDK where you can create a new SLAKPIInstance and associate that with the regarding case / incident, but I can't see where the relationship between that instance and the SLA it selects is.

I've reviewed the entitlements way to do this, but that could cause a lot more maintenance because you have to apply it to ALL your account or contact records, of which we have many thousands.

Seems like you should be able to query the appropriate SLA record, then apply it to the case when it gets created?

*This post is locked for comments

I have the same question (0)
  • Verified answer
    ChrisH5491 Profile Picture
    20 on at

    I did a little more research, and I think I came up with a plan to make this work.

    1. Create an SLA for East and West Coast

    2. Create an Entitlement for East and West Coast, and set the number of cases to 9,999,999. Associate each with the appropriate SLA

    3. In the plugin code for a new incident, put something like this in.         

    Entitlement _e = new Entitlement();
    
    // TODO: Insert some code here to determine contact's time zone and select the right entitlement
    _e = _crm.EntitlementSet
       .Where(e => e.StateCode.Value == EntitlementState.Active)
       .Where(e => e.Name == "Ticket Entitlement (EST)")
       .FirstOrDefault();
    
    if (_e != null)
    {
       UpdateNeeded = true;
       Incident.Entitlementid = new EntityReference(Entitlement.EntityLogicalName, _e.Id);
    }


    Basically you can lookup and set the entitlement for the case based on the time zone, which applies the appropriate SLA.

    I haven't worked out if I will still have to have entitlement for each Account record, but that won't be as bad as having it for each contact.

  • Community Member Profile Picture
    on at

    and what did you put in 'main customer' of the entitlement (which is a mandatory field) ??

    thanks.

  • Suggested answer
    Siraj M Profile Picture
    on at

    Hi Chris,

    Instead of updating the entitlementid, you can retrieve all your SLA's and set the appropriate SLA guid to slaid field in Incindent entity

    Regards,

    Siraj

  • Sachin Dev Gupta Profile Picture
    on at

    Can I retrieve SLAid in CRM 2015 and assign a new SLA to incident?

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Congratulations to our 2025 Community Spotlights

Thanks to all of our 2025 Community Spotlight stars!

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
Varsha deshpande Profile Picture

Varsha deshpande 5

#2
NeerajPawar Profile Picture

NeerajPawar 2

#2
jlattimer Profile Picture

jlattimer 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans