I have created a plugin through visual studio.
Here are the important parts of my code
protected override void Execute(CodeActivityContext param_executionContext)
{
# region tracingService
this.executionContext = param_executionContext;
tracingService = executionContext.GetExtension<ITracingService>();
if (tracingService == null)
{
throw new InvalidPluginExecutionException("Failed to retrieve tracing service.");
}
tracingService.Trace("Entered VendorActivityCreatesHelpDeskActivity.Execute(), Activity Instance Id: {0}, Workflow Instance Id: {1}",
executionContext.ActivityInstanceId,
executionContext.WorkflowInstanceId);
# endregion
# region Context
IWorkflowContext context = executionContext.GetExtension<IWorkflowContext>();
if (context == null)
{
throw new InvalidPluginExecutionException("Failed to retrieve workflow context.");
}
tracingService.Trace("VendorActivityCreatesHelpDeskActivity.Execute(), Correlation Id: {0}, Initiating User: {1}",
context.CorrelationId,
context.InitiatingUserId);
IOrganizationServiceFactory serviceFactory = executionContext.GetExtension<IOrganizationServiceFactory>();
service = serviceFactory.CreateOrganizationService(context.UserId);
// Get HelpDesk Entity
string fetchXMLString_HelpDesk =
"<fetch mapping='logical'>" +
"<entity name='tsi_helpdesk'>" +
"<attribute name='activityid' />" +
"<attribute name='tsi_customeremailaddress' />" +
"<attribute name='tsi_zendesknumber' />" +
"<attribute name='subject' />" +
"<attribute name='tsi_iscreatedatcrm' />" +
"<attribute name='tsi_source' />" +
"<attribute name='statecode' />" +
"<attribute name='statuscode' />" +
"<attribute name='tsi_lastupdater' />" +
"<attribute name='actualend' />" +
"<filter type='and'>" +
"<condition attribute='activityid' operator='eq' value='" + helpDeskID + "' />" +
"</filter>" +
"</entity>" +
"</fetch>";
EntityCollection entCollection_HelpDesk = service.RetrieveMultiple(new FetchExpression(fetchXMLString_HelpDesk));
if (entCollection_HelpDesk.Entities.Count > 0)
{
entity_helpdesk = entCollection_HelpDesk.Entities[0];
if(entity_helpdesk.Attributes.Contains("actualend"))
{
/// EVEN AFTER THERE IS A VALUE FOR ACTUAL END - THE CODE NEVER COMES HERE
helpDeskActualEndTime = entity_helpdesk["actualend"].ToString();
}
}
}
Refer to the part
/// EVEN AFTER THERE IS A VALUE FOR ACTUAL END - THE CODE NEVER COMES HERE
So, the first time when the helpdesk activity is active the code does not hit. But when I resolve the activity and I see in the db that there is a value for actualend - the code still does not get hit.
I have a feeling its staying cached - could some one please help me
protectedoverridevoid Execute(CodeActivityContext param_executionContext)
{
# region tracingService
this.executionContext = param_executionContext;
tracingService = executionContext.GetExtension<ITracingService>();
if (tracingService == null)
{
thrownewInvalidPluginExecutionException("Failed to retrieve tracing service.");
}
tracingService.Trace("Entered VendorActivityCreatesHelpDeskActivity.Execute(), Activity Instance Id: {0}, Workflow Instance Id: {1}",
executionContext.ActivityInstanceId,
executionContext.WorkflowInstanceId);
# endregion
# region Context
IWorkflowContext context = executionContext.GetExtension<IWorkflowContext>();
if (context == null)
{
thrownewInvalidPluginExecutionException("Failed to retrieve workflow context.");
}
tracingService.Trace("VendorActivityCreatesHelpDeskActivity.Execute(), Correlation Id: {0}, Initiating User: {1}",
context.CorrelationId,
context.InitiatingUserId);
IOrganizationServiceFactory serviceFactory = executionContext.GetExtension<IOrganizationServiceFactory>();
service = serviceFactory.CreateOrganizationService(context.UserId);