Hi Bipin,
I have checked with process & created case record from console still its not reflecting the correct BPF but in trace log i am getting the incident id all rcoming fine.
Please find the below code am using
Entity incident = null;
if (executionContext.InputParameters.Contains("Target") && (executionContext.InputParameters["Target"] is Entity))
incident = (Entity)executionContext.InputParameters["Target"];
tracingService.Trace($"Get Incident Id : " + incident.Id);
if (executionContext.Depth <= 3)
{
tracingService.Trace($"Depth is less than 3");
//EntityReference categoryType = null;
//Entity createPostImage = (Entity)executionContext.PostEntityImages["ConflictofInterestPostImage"];
//if (createPostImage.Contains("mdc_interactiontype"))
// categoryType = (EntityReference)createPostImage["mdc_interactiontype"];
try
{
tracingService.Trace($"Triggering here....");
organizationServiceContext.ClearChanges();
//get the values of the case
var incidentDetails = (from tra in organizationServiceContext.CreateQuery("incident")
where (Guid)tra["incidentid"] == incident.Id
select new
{
Id = tra.Contains("incidentid") ? (Guid)tra["incidentid"] : Guid.Empty,
InteractionType = tra.Contains("mdc_interactiontype") ? ((EntityReference)tra["mdc_interactiontype"]).Name : string.Empty
}).FirstOrDefault();
tracingService.Trace($"Get Incident : " + incident.Id);
if (incidentDetails.InteractionType.ToLower() == "conflict of interest")
{
SetProcessRequest request = new SetProcessRequest();
request.Target = new EntityReference("incident", incident.Id);
// THE BELOW POINTS TO THE CORRECT GUID OF THE BUSINESS PROCESS FLOW
request.NewProcess = new EntityReference("process", Guid.Parse("7A538A01-DD47-4335-833E-11E8F9BAD906"));
organizationService.Execute(request);
tracingService.Trace($"COI BPF gets updated here....");
}
else if (incidentDetails.InteractionType.ToLower() == "gift & entertainment")
{
SetProcessRequest request = new SetProcessRequest();
request.Target = new EntityReference("incident", incident.Id);
// THE BELOW POINTS TO THE CORRECT GUID OF THE BUSINESS PROCESS FLOW
request.NewProcess = new EntityReference("process", Guid.Parse("57E8BC82-F936-4CBA-B6C6-18A7C3E270A2"));
organizationService.Execute(request);
tracingService.Trace($"GE BPF gets updated here....");
}
UpdateReporterDetails(incident, tracingService);
tracingService.Trace($"Reporter Details Updated....");
try
{
if (executionContext.MessageName.ToUpper() == "UPDATE")
{
if (executionContext.InputParameters.Contains("Target") && executionContext.InputParameters["Target"] is Entity)
{
Entity entity = (Entity)executionContext.InputParameters["Target"];
if (entity.Contains("mdc_action") && entity["mdc_action"] != null)
{
OptionSetValue value = (OptionSetValue)entity.Attributes["mdc_action"];
int action = value.Value;
if (action == 755040000) //Approved
{
//Move To Next Stage
ChangeStage(tracingService, entity);
tracingService.Trace($"Stage moved to next....");
}
}
}
}
}
From Trace log in below :
Get Incident Id : 8f2c207d-b3ea-ea11-a824-001dd8b70014
Depth is less than 3
Triggering here....
Get Incident : 8f2c207d-b3ea-ea11-a824-001dd8b70014
GE BPF gets updated here....
ReporterName : 89 Al Hammadi
Case has been Updated
Reporter Details Updated....
And checked in Advanced fiend with the Process entity like GE Group process entity then while am opening the record its showing Record is Unavailable error The requested record was not found or you do not have sufficient permission to view it.& by downloading log file showing the process id doesn't exist.
Here always by default process am setting with different process so getting here 2 processes one is default & another one GE group process thats why always its taking default one.
But how can i check the process condition to make apply on create id case.
Thanks,
Jharana