{"id":2539,"date":"2013-02-21T09:13:06","date_gmt":"2013-02-21T09:13:06","guid":{"rendered":"https:\/\/www.wapshere.com\/missmiis\/?p=2539"},"modified":"2013-02-21T09:13:06","modified_gmt":"2013-02-21T09:13:06","slug":"scheduled-notifications-from-the-fim-portal","status":"publish","type":"post","link":"https:\/\/www.wapshere.com\/missmiis\/scheduled-notifications-from-the-fim-portal","title":{"rendered":"Scheduled notifications from the FIM Portal"},"content":{"rendered":"<p>I was asked today to implement notification emails on changes to certain groups. Like many situations with the FIM Portal this turned out to be trickier than expected. A number of the groups are criteria-based so don&#8217;t actually have a member attribute as such. With no member-update request happening there&#8217;s nothing to actually trigger a notification workflow on.<\/p>\n<p>Fortunately the customer was happy to have a daily scheduled email with a summary of changes, rather than immediate emails on every change.\u00c2\u00a0So I took inspiration from Bob Bradley&#8217;s <a href=\"https:\/\/unifysolutions.jira.com\/wiki\/display\/FIMTEAMCOM\/Designing+and+scheduling+Housekeeping+policy+entirely+within+the+FIM+Portal\">Housekeeping Policy<\/a> approach\u00c2\u00a0to solve\u00c2\u00a0the problem.<\/p>\n<p><!--more--><\/p>\n<h2>ROPU Workflows<\/h2>\n<p>The first thing to know about is the &#8220;Run on policy update&#8221; workflow.<\/p>\n<p><img decoding=\"async\" class=\"alignnone\" alt=\"\" src=\"https:\/\/www.wapshere.com\/missmiis\/wp-content\/uploads\/2013\/02\/ropuWP1.jpg\" \/><\/p>\n<p>When combined with a &#8220;Transition In&#8221; MPR this has the very useful effect of re-applying the policy to all members of the Transition In Set upon any change to the MPR.\u00c2\u00a0&#8220;Any change&#8221; includes\u00c2\u00a0enabling the MPR, so\u00c2\u00a0this is a simple way to force the policy to run against\u00c2\u00a0all the objects that are <em>already in the set <\/em>&#8211; effectively re-running any Action workflows, such as a notification.<\/p>\n<p>So all I need to do is get an object in a set, make my ROPU workflow, then just toggle the Disabled switch off and on for the MPR when I want to fire the notification. Easy!<\/p>\n<h2>Workflow Configuration<\/h2>\n<p>The first thing my workflow does is call the <a href=\"http:\/\/fimpowershellwf.codeplex.com\/\">PowerShell activity<\/a> to gather the information I want to insert into the email. I format it as HTML and then pass it back to the workflow in a WorkflowData parameter.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone\" alt=\"\" src=\"https:\/\/www.wapshere.com\/missmiis\/wp-content\/uploads\/2013\/02\/ropuWF2.jpg\" width=\"725\" height=\"210\" \/><\/p>\n<p>The Email Template then simply includes the WorkflowData parameter:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone\" alt=\"\" src=\"https:\/\/www.wapshere.com\/missmiis\/wp-content\/uploads\/2013\/02\/ropuET.jpg\" width=\"609\" height=\"325\" \/><\/p>\n<p>&nbsp;<\/p>\n<h2>Transition Set and MPR<\/h2>\n<p>Before I can create the MPR I need to create a set. It really doesn&#8217;t matter what is in the set in this example as I&#8217;m not using any values from the Target in the workflow, however I only want it to have one member so the notification only triggers once.\u00c2\u00a0For convenience I have the object receiving the notification as the member.\u00c2\u00a0(I expect I could extend this idea to include other objects needing notifications as well, though I&#8217;d need some logic matching set-members to their specific notification requirements.)<\/p>\n<p>The MPR is then very simple to set up:<\/p>\n<ul>\n<li>Type: Transition In<\/li>\n<li>Disabled: True<\/li>\n<li>Set: The set I created above<\/li>\n<li>Action Workflow: The Notification workflow<\/li>\n<\/ul>\n<h2>Toggling the MPR<\/h2>\n<p>The final step is a simple little script that enables and then immediately disables the MPR, and which you can schedule as required.<\/p>\n<p>This script uses the FIMPowerShell Function library from <a href=\"http:\/\/technet.microsoft.com\/en-us\/library\/ff720152(v=ws.10).aspx\">http:\/\/technet.microsoft.com\/en-us\/library\/ff720152(v=ws.10).aspx<\/a><br \/>\n\u00c2\u00a0<\/p>\n<pre>PARAM ($MPRName)\r\n\r\n# Enables then disables an MPR.\r\n# Used to trigger ROPU workflow.\r\n\r\n. E:\\scripts\\FIMPowerShell.ps1\r\n\r\n$Filter = \"\/ManagementPolicyRule[DisplayName='{0}']\" -f $MPRName\r\n\r\n$MPRObj = export-fimconfig -CustomConfig $Filter -OnlyBaseResources\r\n\r\n$ModifyImportObject = ModifyImportObject -TargetIdentifier $MPRObj.ResourceManagementObject.ObjectIdentifier -ObjectType \"ManagementPolicyRule\"\r\nSetSingleValue -ImportObject $ModifyImportObject -AttributeName \"Disabled\" -NewAttributeValue \"False\"\r\n$ModifyImportObject | Import-FIMConfig\r\n\r\n$ModifyImportObject = ModifyImportObject -TargetIdentifier $MPRObj.ResourceManagementObject.ObjectIdentifier -ObjectType \"ManagementPolicyRule\"\r\nSetSingleValue -ImportObject $ModifyImportObject -AttributeName \"Disabled\" -NewAttributeValue \"True\"\r\n$ModifyImportObject | Import-FIMConfig<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>I was asked today to implement notification emails on changes to certain groups. Like many situations with the FIM Portal this turned out to be trickier than expected. A number of the groups are criteria-based so don&#8217;t actually have a member attribute as such. With no member-update request happening there&#8217;s nothing to actually trigger a&#8230;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"footnotes":"","jetpack_publicize_message":"","jetpack_is_tweetstorm":false,"jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":[]},"categories":[42,60,62,23,45],"tags":[],"class_list":["post-2539","post","type-post","status-publish","format-standard","hentry","category-fim-2010","category-fim-2010-r2","category-mpr","category-powershell","category-workflow"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_shortlink":"https:\/\/wp.me\/pkp1o-EX","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/www.wapshere.com\/missmiis\/wp-json\/wp\/v2\/posts\/2539","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.wapshere.com\/missmiis\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.wapshere.com\/missmiis\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.wapshere.com\/missmiis\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.wapshere.com\/missmiis\/wp-json\/wp\/v2\/comments?post=2539"}],"version-history":[{"count":10,"href":"https:\/\/www.wapshere.com\/missmiis\/wp-json\/wp\/v2\/posts\/2539\/revisions"}],"predecessor-version":[{"id":2552,"href":"https:\/\/www.wapshere.com\/missmiis\/wp-json\/wp\/v2\/posts\/2539\/revisions\/2552"}],"wp:attachment":[{"href":"https:\/\/www.wapshere.com\/missmiis\/wp-json\/wp\/v2\/media?parent=2539"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wapshere.com\/missmiis\/wp-json\/wp\/v2\/categories?post=2539"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wapshere.com\/missmiis\/wp-json\/wp\/v2\/tags?post=2539"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}