{"id":23100,"date":"2020-03-16T12:13:26","date_gmt":"2020-03-16T12:13:26","guid":{"rendered":"https:\/\/www.inogic.com\/blog\/?p=23100"},"modified":"2020-03-16T12:13:26","modified_gmt":"2020-03-16T12:13:26","slug":"programmatically-register-post-or-pre-image-for-plugin-step-with-required-attribute-parameters","status":"publish","type":"post","link":"https:\/\/www.inogic.com\/blog\/2020\/03\/programmatically-register-post-or-pre-image-for-plugin-step-with-required-attribute-parameters\/","title":{"rendered":"Programmatically register Post or Pre Image for plugin step with required attribute parameters"},"content":{"rendered":"<h2><strong>Introduction<\/strong><\/h2>\n<p>There is a client requirement to register a plugin dynamically on update of owner field.<\/p>\n<p>In this blog we will explain how to get only required attribute parameters while registering Post or Pre image for plugin step.<\/p>\n<p>If you want to programmatically validate Pre\/Post plugin step then please refer <a href=\"https:\/\/www.inogic.com\/blog\/2020\/02\/programmatically-validate-pre-post-plugin-step\/\" target=\"_blank\" rel=\"noopener noreferrer\">this<\/a>.<\/p>\n<p><strong>Below is code for to register pre or post image with required filter attributes &#8211;<\/strong><\/p>\n<pre class=\"lang:default decode:true \">var image = new Entity(\"sdkmessageprocessingstepimage\");\r\n\r\nif (stage == 0)\r\n\r\n{\r\n\r\nimage.SetAttributeValue(\"imagetype\", new OptionSetValue(Convert.ToInt32(SdkPlugins.ImageType.PreImage)));\/\/Pre-image stands for 0\r\n\r\nimage.SetAttributeValue(\"name\", \"AssignPreImage\");\r\n\r\nimage.SetAttributeValue(\"entityalias\", \"AssignPreImage\");\r\n\r\n}\r\n\r\nelse\r\n\r\n{\r\n\r\nimage.SetAttributeValue(\"imagetype\", new OptionSetValue(Convert.ToInt32(SdkPlugins.ImageType.PostImage)));\/\/Post-image stands for 1\r\n\r\nimage.SetAttributeValue(\"name\", \"AssignPostImage\");\r\n\r\nimage.SetAttributeValue(\"entityalias\", \"AssignPostImage\");\r\n\r\n}\r\n\r\n<strong>\/\/Here you can add attributes which you want to get from image<\/strong>\r\n\r\nimage.SetAttributeValue(\"<strong>attributes<\/strong>\",<strong> \"ownerid\"<\/strong>);\r\n\r\nimage.SetAttributeValue(\"sdkmessageprocessingstepid\", new EntityReference(\"sdkmessageprocessingstep\", stepId));\r\n\r\nimage.SetAttributeValue(\"messagepropertyname\", \"Target\");\r\n\r\nserviceContext.Create(image);<\/pre>\n<h2>Conclusion<\/h2>\n<p>Thus you have seen how to fetch only required attribute parameters while registering Post or Pre image for plugin step using this code.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>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\u2026 <span class=\"read-more\"><a href=\"https:\/\/www.inogic.com\/blog\/2020\/03\/programmatically-register-post-or-pre-image-for-plugin-step-with-required-attribute-parameters\/\">Read More &raquo;<\/a><\/span><\/p>\n","protected":false},"author":13,"featured_media":23102,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"om_disable_all_campaigns":false,"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"categories":[18,42],"tags":[545],"class_list":["post-23100","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-dynamics-365-v9-2","category-plugin","tag-dynamics-365-crm"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/www.inogic.com\/blog\/wp-json\/wp\/v2\/posts\/23100","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.inogic.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.inogic.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.inogic.com\/blog\/wp-json\/wp\/v2\/users\/13"}],"replies":[{"embeddable":true,"href":"https:\/\/www.inogic.com\/blog\/wp-json\/wp\/v2\/comments?post=23100"}],"version-history":[{"count":0,"href":"https:\/\/www.inogic.com\/blog\/wp-json\/wp\/v2\/posts\/23100\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.inogic.com\/blog\/wp-json\/wp\/v2\/media\/23102"}],"wp:attachment":[{"href":"https:\/\/www.inogic.com\/blog\/wp-json\/wp\/v2\/media?parent=23100"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.inogic.com\/blog\/wp-json\/wp\/v2\/categories?post=23100"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.inogic.com\/blog\/wp-json\/wp\/v2\/tags?post=23100"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}