Quantcast
Channel: Microsoft Dynamics CRM Forum - Recent Threads
Viewing all articles
Browse latest Browse all 79901

Unable activate SLA created using code and SDK.

$
0
0

Hi All,

I have been trying to create SLA and SLA Item using code and SDK as I have to create around 500 SLAs.

I am able to create SLA using code but when I try to activate SLA , it throws error.

I checked error log. It shows some unexpected error occurred.

I have few observations:

1. when I remove SLA Items from SLA , then I am able to Activate SLA. So, Problem is creation of SLA Items.

2. I created one SLA Item manually and When I opened one manually created SLA Item and one auto created SLA Item, I found one difference that  on manual SLA Item,  "Add Step" buttons are visible below Success Action, Failure Action, Warning Action. But on auto created SLAItem , those buttons are not visible. I checked  all properties of SLA Item but I found no difference.

I think Actions linked on SLAItem must be stored somewhere in different entity. But I dont know that relationship and entity name.

Manual SLA Item:

Code Created SLA Item

Code used to create SLA Item:

SLAItem slaitem1 = new SLAItem();
slaitem1.SLAId = sla.ToEntityReference();
slaitem1.Name = "SLAItem-CS" + dt.Rows[rowIndex][1].ToString() + "-" + dt.Rows[rowIndex][2].ToString();
slaitem1.SequenceNumber = counter2;
slaitem1.RelatedField = "hpi_slakpi";
slaitem1.ApplicableWhenXml = "<and><condition><column id=\"colEntity\" value=\"hpi_complaintsolution\" /><column id=\"colAttribute\" value=\"hpi_complaintsolutionstatus\"/><column id=\"colOperator\" value=\"eq\"/><column id=\"colStaticValue\" value=\"" + dt.Rows[rowIndex][3].ToString() + "\" dataslugs=\"\" /></condition></and>";
slaitem1.SuccessConditionsXml = "<and><condition><column id=\"colEntity\" value=\"hpi_complaintsolution\" /><column id=\"colAttribute\" value=\"statecode\"/><column id=\"colOperator\" value=\"eq\"/><column id=\"colStaticValue\" value=\"1\" dataslugs=\"\" /></condition></and>";
slaitem1.FailureAfter = ((int)dt.Rows[rowIndex][4]) * 60;
slaitem1.WarnAfter = ((int)dt.Rows[rowIndex][4]) * 30; // 50%

Console.WriteLine(counter.ToString() + "-" + counter2.ToString() + " SLA Item Creating...");
slaitem1.Id = orgService.Create(slaitem1);
Console.WriteLine(counter.ToString() + "-" + counter2.ToString() + " SLA Item Created.");

Please suggest how can I create SLA Item and its Actions correctly so that later I can activate SLA.


Viewing all articles
Browse latest Browse all 79901


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>