Skip to content

Commit 8d94672

Browse files
committed
SetState & SetStateDynamicEntity use message property of EntityMoniker
1 parent 921bde4 commit 8d94672

File tree

1 file changed

+22
-11
lines changed

1 file changed

+22
-11
lines changed

spkl/SparkleXrm.Tasks/PluginRegistraton.cs

+22-11
Original file line numberDiff line numberDiff line change
@@ -456,23 +456,34 @@ private SdkMessageProcessingStepImage RegisterImage(CrmPluginRegistrationAttribu
456456
{
457457
return null;
458458
}
459-
var image = existingImages.Where(a =>
460-
a.SdkMessageProcessingStepId.Id == step.Id
461-
&&
462-
a.EntityAlias == imageName
463-
&& a.ImageType == (sdkmessageprocessingstepimage_imagetype)imagetype).FirstOrDefault();
464-
if (image == null)
465-
{
466-
image = new SdkMessageProcessingStepImage();
467-
}
459+
460+
var image = existingImages.FirstOrDefault(
461+
a => a.SdkMessageProcessingStepId.Id == step.Id
462+
&& a.EntityAlias == imageName
463+
&& a.ImageType == (sdkmessageprocessingstepimage_imagetype)imagetype) ??
464+
new SdkMessageProcessingStepImage();
468465

469466
image.Name = imageName;
470-
467+
471468
image.ImageType = (sdkmessageprocessingstepimage_imagetype)imagetype;
472469
image.SdkMessageProcessingStepId = new EntityReference(SdkMessageProcessingStep.EntityLogicalName, step.Id);
473470
image.Attributes1 = attributes;
474471
image.EntityAlias = imageName;
475-
image.MessagePropertyName = stepAttribute.Message == "Create" ? "Id" : "Target";
472+
473+
switch (stepAttribute.Message)
474+
{
475+
case "Create":
476+
image.MessagePropertyName = "Id";
477+
break;
478+
case "SetState":
479+
case "SetStateDynamicEntity":
480+
image.MessagePropertyName = "EntityMoniker";
481+
break;
482+
default:
483+
image.MessagePropertyName = "Target";
484+
break;
485+
}
486+
476487
if (image.Id == Guid.Empty)
477488
{
478489
_trace.WriteLine("Registering Image '{0}'", image.Name);

0 commit comments

Comments
 (0)