Programmatically register Post or Pre Image for plugin step with required attribute parameters

Sending
User Review
0 (0 votes)

Introduction

There is a client requirement to register a plugin dynamically on update of owner field.

In this blog we will explain how to get only required attribute parameters while registering Post or Pre image for plugin step.

If you want to programmatically validate Pre/Post plugin step then please refer this.

Below is code for to register pre or post image with required filter attributes –

var image = new Entity("sdkmessageprocessingstepimage"); if (stage == 0) { image.SetAttributeValue("imagetype", new OptionSetValue(Convert.ToInt32(SdkPlugins.ImageType.PreImage)));//Pre-image stands for 0 image.SetAttributeValue("name", "AssignPreImage"); image.SetAttributeValue("entityalias", "AssignPreImage"); } else { image.SetAttributeValue("imagetype", new OptionSetValue(Convert.ToInt32(SdkPlugins.ImageType.PostImage)));//Post-image stands for 1 image.SetAttributeValue("name", "AssignPostImage"); image.SetAttributeValue("entityalias", "AssignPostImage"); } //Here you can add attributes which you want to get from image image.SetAttributeValue("attributes", "ownerid"); image.SetAttributeValue("sdkmessageprocessingstepid", new EntityReference("sdkmessageprocessingstep", stepId)); image.SetAttributeValue("messagepropertyname", "Target"); serviceContext.Create(image);

Conclusion

Thus you have seen how to fetch only required attribute parameters while registering Post or Pre image for plugin step using this code.