scottdurow / SparkleXrm

An open-source library for building Dynamics CRM XRM solutions using Script#, jQuery & Knockoutjs.
MIT License
265 stars 197 forks source link

Unable to register images for plug-in steps for bulk messages (CreateMultiple/UpdateMultiple) #486

Open simon-tooley-t4a opened 1 month ago

simon-tooley-t4a commented 1 month ago

An exception is generated when attempting to sparkle a plug-in containing an image that has been configured for a bulk message, i.e. CreateMultiple or UpdateMultiple.

The exception is: 'Message property name 'Target' is not valid on message UpdateMultiple.'

simon-tooley-t4a commented 1 month ago

On investigation I've found that the issue exists within the RegisterImage method of the PluginRegistration.cs.

` switch (stepAttribute.Message) { case "Create": image.MessagePropertyName = "Id"; break;

            case "SetState":
            case "SetStateDynamicEntity":
                image.MessagePropertyName = "EntityMoniker";
                break;

            case "Send":
            case "DeliverIncoming":
            case "DeliverPromote":
                image.MessagePropertyName = "EmailId";
                break;

            default:
                image.MessagePropertyName = "Target";
                break;
        }

`

Making the following change to the switch statement would appear to fix the issue:

default: image.MessagePropertyName = (stepAttribute.Message.ToLower() == "createmultiple" || stepAttribute.Message.ToLower() == "updatemultiple") ? "Targets" : "Target"; break;

simon-tooley-t4a commented 1 month ago

Discovered that CreateMultiple requires the property name of Ids rather than target