I wanted to enable custom time calculation for SLA KPIs which is provided in the following link: Enable Custom time calculation of SLA KPIs
However, could you please help me with plugin. I do not understand how to write FetchCalendar method?
if (caseRecord.Attributes.Contains("new_country"))
{
customCode = (int)(((OptionSetValue)(caseRecord.Attributes["new_country"])).Value);
// Example 1: Override calendar at runtime: Choose Calendar based on any custom logic
if (customCode == 0)
{
// fetch IST calendar & override CalendarId
IST_CALENDAR = FetchCalendar("IST_CALENDAR", _service);
calendarId = IST_CALENDAR;
}
else if (customCode == 1)
{
// fetch PST calendar & override CalendarId
PST_CALENDAR = FetchCalendar("PST_CALENDAR", _service);
calendarId = PST_CALENDAR;
}
}
Best Regards, M
Below is kind of Psudeo code, you might have to check with synatx.
private Guid FetchCalendar(string calendarName, OrganizationService _service){
Guid calendarId=Guid.Empty();
// Instantiate QueryExpression query
var query = new QueryExpression("calendar");
// Add all columns to query.ColumnSet
query.ColumnSet.AllColumns = true;
// Define filter query.Criteria
query.Criteria.AddCondition("name", ConditionOperator.Equal, calendarName /* "IST_CALENDAR"*/);
EntityCollection _calendarsCollection = _service.RetrieveMulitple(query);
if(_calendarsCollection.Entities.Count>0){
calendarId =_calendarsCollection.Entities[0].Id;
}
return calendarId;
}