Showing posts with label SLA Timer. Show all posts
Showing posts with label SLA Timer. Show all posts

Thursday, 14 April 2016

How to retrieve SLA Pause States (On Hold Case Status) in C# code


Following code shows how to retrieve SLA Pause States from Dynamics CRM using C#. I needed code a functionality to calculate case elapsed minutes and I thought it is worth finding a way to load paused statuses from system rather than hard-coding them.


        private static string[] GetSlaPauseStates(IOrganizationService service)
        {
            QueryExpression qe = new QueryExpression("organization")
            {
ColumnSet = new ColumnSet(new string[] { "organizationid", "slapausestates" })
            };

            EntityCollection orgs = service.RetrieveMultiple(qe);

            if (orgs != null && orgs.Entities.Count > 0)
            {
                var org = orgs[0];
                var slaPauseStates = orgs[0]["slapausestates"];
                string[] states = slaPauseStates.ToString().Split(';');
                return states;
            }

            return null;
        }

In Plugin or Custom Workflow we can retrieve the OrganizationId from contact and then we can directly retrieve the Organization by Id. Following is the code to retrieve organizationId.


    IWorkflowContext context = executionContext.GetExtension<IWorkflowContext>();
    IOrganizationServiceFactory serviceFactory =      executionContext.GetExtension<IOrganizationServiceFactory>();
    IOrganizationService service = serviceFactory.CreateOrganizationService(context.UserId);

    var organizationId = context.OrganizationId;

    // Get Organization Business Closure Calendar Id
    var organization = service.Retrieve("organization", context.OrganizationId, new ColumnSet("slapausestates"));
    var slaPauseStates = organization["slapausestates"];

    string[] states = slaPauseStates.ToString().Split(';');


Happy Coding

P. S. Hayer
(ਪ੍ਰੇਮਜੀਤ ਸਿੰਘ ਹੇਰ)
Premjit Singh
Attendite Ltd.
Twitter

Thursday, 19 June 2014

CRM 2013: Timer button is currently disabled

Service pack 1 of Dynamics CRM 2013 came up with an exciting feature of SLA Timer. Timers can be used to track service level agreement KPI to ensure customer commitments are met. Today I was trying to get my hands on it but after installing Service Pack 1, I discovered that Timer option was greyed out on form editor. It was saying:

"This button is currently disabled".

"You may not have selected the item that works with this feature. If you don not have permissions to use this feature, correct your system."


 Solution: 

Go to Settings > Administration > Install Product Updates

You will get the following screen.

Install the updated by clicking on 'Update' at the bottom of the screen.

it will install the updated and in the mean time you can watch the video on installation screen to know more about this brilliant feature. Once updated you will get the confirmation screen. 

Open case form in form editor. You will see that 'Timer' button is enabled not and it is ready to use. 



P. S. Hayer
(ਪ੍ਰੇਮਜੀਤ ਸਿੰਘ ਹੇਰ)
Please check my other (non-CRM) blog here: Programming Blogs