locked
Relationship Subscription mixed with a Instance Subscription RRS feed

  • Question

  • Hi,

    is it possible to combine an Relationshipsubscription with an Instance Subscription? For example i want to check if a Activity is updated and in the status ActivityStatusEnum.Active and the assignedTo User has changed.

     

    Monday, December 9, 2013 11:56 AM

Answers

  • Eden,

    I've improved the solution to add a support for Review Activities. You can download the files and source code from our new blog post ;)


    Cheers,
    Marat
    Site: www.scutils.com  Twitter: LinkedIn: Graveyard:

    • Edited by Marat Kuanyshev Wednesday, December 17, 2014 1:12 PM
    • Marked as answer by Sysadmin21 Thursday, December 18, 2014 1:44 PM
    Wednesday, December 17, 2014 5:58 AM
  • Well, Eden, I've also spent my time trying to make your project working with 'Send Email Notification' but gave up and created a solution in Visual Studio. So, you are a lucky man. I've posted the solution here in our corporate blog.

    You (and not only you :)) can find there the required files and a source code if you want to change something. Enjoy!!!

    P.S. Sometimes I feel like MVP but I'm not lol


    Cheers,
    Marat
    Site: www.scutils.com  Twitter: LinkedIn: Graveyard:

    • Proposed as answer by Eden Ravenwood Tuesday, December 16, 2014 11:40 PM
    • Marked as answer by Sysadmin21 Thursday, December 18, 2014 1:44 PM
    Tuesday, December 16, 2014 10:54 AM
  • Sorry, it's not possible to combine these two

    Rob Ford scsmnz.net
    Cireson www.cireson.com
    For a free SCSM 2012 Notify Analyst app click here

    • Marked as answer by Sysadmin21 Wednesday, December 11, 2013 4:40 PM
    Tuesday, December 10, 2013 8:26 PM

All replies

  • Sorry, it's not possible to combine these two

    Rob Ford scsmnz.net
    Cireson www.cireson.com
    For a free SCSM 2012 Notify Analyst app click here

    • Marked as answer by Sysadmin21 Wednesday, December 11, 2013 4:40 PM
    Tuesday, December 10, 2013 8:26 PM
  • Ok, thanks for the reply.
    Wednesday, December 11, 2013 4:40 PM
  • However, it would be possible to trigger the workflow and run a custom workflow with one condition and then test for the other condition. You could create a custom workflow with the Authoring Tool that calls PowerShell to do this, or create a custom workflow assembly in C#.

    Rob Ford scsmnz.net
    Cireson www.cireson.com
    For a free SCSM 2012 Notify Analyst app click here

    Wednesday, December 11, 2013 8:20 PM
  • I'd been trying to work out how you might do this as well, and I think ive come up with a solution:

    Create a queue that is defined by the status of the work item you are targeting, i.e. all manual activities that are in progress.  Then use that queue to limit the scope of your subscription based on the assigned to user relationship.  I'm just about to test it so ill let you know how it goes.


    Wednesday, December 10, 2014 5:38 AM
  • Maybe not it seems that limiting a scope by queue is a capability specific to instance subcriptions,  the XML looks like this:

    <InstanceSubscription Type="7ac62bd4-8fce-a150-3b40-16a39a61383d">
      <UpdateInstance>
        <Groups>
          <GroupId>75dbc0ac-fffc-d9fb-d327-998149d28277</GroupId>
        </Groups>
        <Criteria>
          <Expression>
            <SimpleExpression>
              <ValueExpression>
                <Property State="Post">$Context/Property[Type='WorkItem!System.WorkItem']/Title$</Property>
              </ValueExpression>
              <Operator>Like</Operator>
              <ValueExpression>
                <Value>%abc%</Value>
              </ValueExpression>
            </SimpleExpression>
          </Expression>
        </Criteria>
      </UpdateInstance>
    </InstanceSubscription>

    Where I think the <groups></groups> block is defining the queue that the subscription applies to.

    I attempted to add the groups block to the relationshipsubsciption like so:

    <RelationshipSubscription RelType="$MPElement[Name='WorkItem!System.WorkItemAssignedToUser']$" SourceType="$MPElement[Name='CustomSystem_WorkItem_Activity_Library!System.WorkItem.Activity.ManualActivity']$" TargetType="$MPElement[Name='CustomSystem_Library!System.Domain.User']$">
      <Groups>
        <GroupId>75dbc0ac-fffc-d9fb-d327-998149d28277</GroupId>
      </Groups>
      <AddRelationship />
    </RelationshipSubscription>

    however when I then try to import my MP back in I get this validation error

    : Schema validation failed.
    The element 'RelationshipSubscription' has invalid child element 'Groups'. List of possible elements expected: 'AddRelationship, DeleteRelationship'.

    So alas its back to the drawing board.

    @Rob Ford; can you direct me to any resource that describes how to create a workflow like you discuss above.

    Wednesday, December 10, 2014 10:49 PM
  • Hi Eden,

    This blog post can be very helpful for you because it describes how add new type of the activity in the Authoring Tool - Send Mail Notification. You can combine two ideas:

    1. Create a workflow with AddRelationship trigger
    2. In the Authoring Tool create a workflow with IfElse to check whether the status is 'In Progress'
    3. If Yes, send a notification to assigned user with Oren Beeri's custom activity named 'Send Mail Notification'.

    Cheers,
    Marat
    Site: www.scutils.com  Twitter: LinkedIn: Graveyard:

    Thursday, December 11, 2014 1:29 AM
  • BTW, in the Authoring Tool you cannot create a trigger based on AddRelationship, but you can build any trigger but later change the DataSource in the XML code. Let's know about the result if you decide to follow this way.

    Cheers,
    Marat
    Site: www.scutils.com  Twitter: LinkedIn: Graveyard:

    Thursday, December 11, 2014 1:40 AM
  • Hi Marat,

    Thanks for the lead.  I have been trying to get a solution going based on your suggestion.  I have added the custom activity into my service manager authoring tool and created a workflow based on it.   I have then saved the MP and edited the XML directly to change it from an Instance Subscription to a Relationship Subscription.

    So what I have now (in theory) is a workflow that triggers whenever a Manual activity is assigned to a user, the workflow itself checks if the target activity is 'In Progress' and if it is sends the assigned user a notification, if its not 'In Progress' the workflow does nothing.  After importing the MP into Service Manager I can see the workflow listed but when I assign a Manual Activity the workflow is trigger but fails with this error:

    Error code

    -2130771918

    Error Message

    A module of type "Microsoft.EnterpriseManagement.HealthService.Modules.WorkflowFoundation.WorkflowFoundationWriteActionModule" reported an exception Microsoft.EnterpriseManagement.HealthService.Modules.WorkflowFoundation.InvalidWorkflowAssemblyNameException: The value 'MAInProgressAssignmentNotification' specified for the workflow assembly is invalid.  See Inner exception for information ---> System.IO.FileNotFoundException: Could not load file or assembly 'MAInProgressAssignmentNotification' or one of its dependencies.  The system cannot find the file specified.

    I suspect that this is because the DLL with the Send Email Notification custom workflow activity has been imported into the authoring tool, but not into Service Manager itself,  I have tried copying it (C60.SCSM.WorkflowActivites.dll) to the Service Manager program folder, but this made no difference.

    I noticed that in the folder where the xml MP was saved there were a number of other files (.cs, .rules, .xoml, .xomlx, .dll) so I have tried creating an management pack bundle file using the New-SCSMManagementPackBundle cmdlet but having replaced the xml mp with the mpb mp I still get the same error.

    Is my suspicion correct and if so how do I go about making the custom workflow activities in the C60 dll available within Service Manager and not just the authoring tool?

    If it helps at all here is the xml for the management pack I made:

    <ManagementPack ContentReadable="true" SchemaVersion="2.0" OriginalSchemaVersion="1.1" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
      <Manifest>
        <Identity>
          <ID>ICTB.Notification.ActivityInProgressAssignmentChange</ID>
          <Version>1.0.0.2</Version>
        </Identity>
        <Name>ICTB.Notification.ActivityInProgressAssignmentChange</Name>
        <References>
          <Reference Alias="System">
            <ID>System.Library</ID>
            <Version>7.5.8501.0</Version>
            <PublicKeyToken>31bf3856ad364e35</PublicKeyToken>
          </Reference>
          <Reference Alias="Console">
            <ID>Microsoft.EnterpriseManagement.ServiceManager.UI.Console</ID>
            <Version>7.5.2905.0</Version>
            <PublicKeyToken>31bf3856ad364e35</PublicKeyToken>
          </Reference>
          <Reference Alias="System_WorkItem_Activity_Library">
            <ID>System.WorkItem.Activity.Library</ID>
            <Version>7.5.2905.0</Version>
            <PublicKeyToken>31bf3856ad364e35</PublicKeyToken>
          </Reference>
          <Reference Alias="WorkItem">
            <ID>System.WorkItem.Library</ID>
            <Version>7.5.2905.0</Version>
            <PublicKeyToken>31bf3856ad364e35</PublicKeyToken>
          </Reference>
          <Reference Alias="EnterpriseManagement">
            <ID>Microsoft.EnterpriseManagement.ServiceManager.UI.Administration</ID>
            <Version>7.5.2905.0</Version>
            <PublicKeyToken>31bf3856ad364e35</PublicKeyToken>
          </Reference>
          <Reference Alias="SystemCenter">
            <ID>Microsoft.SystemCenter.Library</ID>
            <Version>7.0.8432.0</Version>
            <PublicKeyToken>31bf3856ad364e35</PublicKeyToken>
          </Reference>
          <Reference Alias="SystemCenter1">
            <ID>Microsoft.SystemCenter.Subscriptions</ID>
            <Version>7.5.2905.0</Version>
            <PublicKeyToken>31bf3856ad364e35</PublicKeyToken>
          </Reference>
          <Reference Alias="CustomSystem_Notifications_Library">
            <ID>System.Notifications.Library</ID>
            <Version>7.5.2905.0</Version>
            <PublicKeyToken>31bf3856ad364e35</PublicKeyToken>
          </Reference>
        </References>
      </Manifest>
      <Categories>
        <Category ID="ICTB.Notification.ActivityInProgressAssignmentChange.Category" Value="Console!Microsoft.EnterpriseManagement.ServiceManager.ManagementPack">
          <ManagementPackName>ICTB.Notification.ActivityInProgressAssignmentChange</ManagementPackName>
          <ManagementPackVersion>1.0.0.1</ManagementPackVersion>
        </Category>
        <Category ID="MAInProgressAssignmentNotificationCategory" Target="MAInProgressAssignmentNotification" Value="EnterpriseManagement!Microsoft.EnterpriseManagement.ServiceManager.Rules.WorkflowSubscriptions" />
        <Category ID="Category.78c53eadbd85467fb577c98ada4a59ee" Target="ObjectTemplate.b5a145775bda4b469856fe9a16e9003a" Value="EnterpriseManagement!ServiceManager.Console.NotificationManagement.NotificationTemplates.Enumeration" />
      </Categories>
      <Monitoring>
        <Rules>
          <Rule ID="MAInProgressAssignmentNotification" Enabled="true" Target="SystemCenter!Microsoft.SystemCenter.SubscriptionWorkflowTarget" ConfirmDelivery="true" Remotable="true" Priority="Normal" DiscardLevel="100">
            <Category>Notification</Category>
            <DataSources>
              <DataSource ID="DS" TypeID="SystemCenter1!Microsoft.SystemCenter.CmdbInstanceSubscription.DataSourceModule">
                <Subscription>
                  <RelationshipSubscription RelType="$MPElement[Name='WorkItem!System.WorkItemAssignedToUser']$" SourceType="$MPElement[Name='System_WorkItem_Activity_Library!System.WorkItem.Activity.ManualActivity']$" TargetType="$MPElement[Name='System!System.Domain.User']$">
                    <AddRelationship />
                  </RelationshipSubscription> <PollingIntervalInSeconds>60</PollingIntervalInSeconds> <BatchSize>100</BatchSize> </Subscription> </DataSource> </DataSources> <WriteActions> <WriteAction ID="WA" TypeID="SystemCenter1!Microsoft.EnterpriseManagement.SystemCenter.Subscription.WindowsWorkflowTaskWriteAction"> <Subscription> <WindowsWorkflowConfiguration> <AssemblyName>MAInProgressAssignmentNotification</AssemblyName> <WorkflowTypeName>WorkflowAuthoring.MAInProgressAssignmentNotification</WorkflowTypeName> <WorkflowParameters> <WorkflowParameter Name="SendEmailNotification_InstanceId" Type="string">$Data/Property[@ID='$MPElement[Name="WorkItem!System.WorkItem"]/Id$' and @State='Post']$</WorkflowParameter> <WorkflowParameter Name="getRelatedEntityActivity1_SourceId" Type="string">$Data/BaseManagedEntityId$</WorkflowParameter> <WorkflowParameter Name="StatusBindHelper_StringProperty" Type="string">$Data/BaseManagedEntityId$</WorkflowParameter> </WorkflowParameters> <RetryExceptions></RetryExceptions> <RetryDelaySeconds>60</RetryDelaySeconds> <MaximumRunningTimeSeconds>300</MaximumRunningTimeSeconds> </WindowsWorkflowConfiguration> </Subscription> </WriteAction> </WriteActions> </Rule> </Rules> </Monitoring> <Templates> <ObjectTemplate ID="ObjectTemplate.b5a145775bda4b469856fe9a16e9003a" TypeID="CustomSystem_Notifications_Library!System.Notification.Template.SMTP"> <Property Path="$Context/Property[Type='CustomSystem_Notifications_Library!System.Notification.Template.SMTP']/Subject$">&lt;1033&gt;[$Context/Property[Type='WorkItem!System.WorkItem']/Id$] Manual Activity Assignment&lt;/1033&gt;</Property> <Property Path="$Context/Property[Type='CustomSystem_Notifications_Library!System.Notification.Template.SMTP']/Priority$">2</Property> <Property Path="$Context/Property[Type='CustomSystem_Notifications_Library!System.Notification.Template.SMTP']/IsBodyHtml$">True</Property> <Property Path="$Context/Property[Type='CustomSystem_Notifications_Library!System.Notification.Template']/Content$">Notification content goes here</Property> <Property Path="$Context/Property[Type='CustomSystem_Notifications_Library!System.Notification.Template']/Encoding$">utf-8</Property> <Property Path="$Context/Property[Type='CustomSystem_Notifications_Library!System.Notification.Template']/SeedClass$">System.WorkItem.Activity.ManualActivity$7ac62bd4-8fce-a150-3b40-16a39a61383d</Property> <Property Path="$Context/Property[Type='CustomSystem_Notifications_Library!System.Notification.Template']/Protocol$">SMTP</Property> </ObjectTemplate> </Templates> <LanguagePacks> <LanguagePack ID="ENA" IsDefault="true"> <DisplayStrings> <DisplayString ElementID="ICTB.Notification.ActivityInProgressAssignmentChange"> <Name>ICTB.Notification.ActivityInProgressAssignmentChange</Name> </DisplayString> </DisplayStrings> </LanguagePack> <LanguagePack ID="ENU" IsDefault="false"> <DisplayStrings> <DisplayString ElementID="ICTB.Notification.ActivityInProgressAssignmentChange"> <Name>ICTB.Notification.ActivityInProgressAssignmentChange</Name> </DisplayString> <DisplayString ElementID="MAInProgressAssignmentNotification"> <Name>MAInProgressAssignmentNotification</Name> </DisplayString> <DisplayString ElementID="ObjectTemplate.b5a145775bda4b469856fe9a16e9003a"> <Name>Email.ManualActivity.AssignedToUser.InProgressAssignmentChange</Name> <Description>Notification Template advising a manual activity's Assigned To User upon assignment or reassignment.</Description> </DisplayString> </DisplayStrings> </LanguagePack> </LanguagePacks> </ManagementPack>



    Monday, December 15, 2014 11:08 PM
  • It probably doesn't help much but this is a screenshot of the workflow in the authoring tool.
    Monday, December 15, 2014 11:19 PM
  • Hi Eden,

    It indeed doesn't help a lot. If you don't worry about your copyright, could you share the whole solution using microsoft skydrive or something like this?

    BTW, have you tried to copy Microsoft.EnterpriseManagement.Notifications.Workflows.dll and Microsoft.EnterpriseManagement.Common.dll as Oren advised in the last comment in that blog post?


    Cheers,
    Marat
    Site: www.scutils.com  Twitter: LinkedIn: Graveyard:

    Tuesday, December 16, 2014 1:25 AM
  • Yes, I did copy Microsoft.EnterpriseManagement.Notifications.Workflows.dll and Microsoft.EnterpriseManagement.Common.dll which was necessary to be able to add the custom activities to the activities toolbox, but those files are copied from the service manager program folder so I'm pretty confident they are not the cause of the problem I'm having. 

    Heres a link to a Zip of what I have so far: ICTB.Notifications.ActivityInProgressAssignmentChange.zip

    Thanks for your input so far Marat.

    -Eden

    Tuesday, December 16, 2014 4:30 AM
  • Well, Eden, I've also spent my time trying to make your project working with 'Send Email Notification' but gave up and created a solution in Visual Studio. So, you are a lucky man. I've posted the solution here in our corporate blog.

    You (and not only you :)) can find there the required files and a source code if you want to change something. Enjoy!!!

    P.S. Sometimes I feel like MVP but I'm not lol


    Cheers,
    Marat
    Site: www.scutils.com  Twitter: LinkedIn: Graveyard:

    • Proposed as answer by Eden Ravenwood Tuesday, December 16, 2014 11:40 PM
    • Marked as answer by Sysadmin21 Thursday, December 18, 2014 1:44 PM
    Tuesday, December 16, 2014 10:54 AM
  • Thank you!!

    I've tested that in my Dev environment and it works perfectly.  I hope you don't mind but I'm going to make a modified version of your work that targets Review Activities, is the DLL specific to the activity type or should that function regardless?

    You can have an Honorary MVP from me not quite as good as the real thing I know but its the best I can do a short notice ;)

    Tuesday, December 16, 2014 11:45 PM
  • Eden,

    I've improved the solution to add a support for Review Activities. You can download the files and source code from our new blog post ;)


    Cheers,
    Marat
    Site: www.scutils.com  Twitter: LinkedIn: Graveyard:

    • Edited by Marat Kuanyshev Wednesday, December 17, 2014 1:12 PM
    • Marked as answer by Sysadmin21 Thursday, December 18, 2014 1:44 PM
    Wednesday, December 17, 2014 5:58 AM
  • Thanks again Marat,

    you've done in a few hours what it would have taken me days to work out.  I really appreciate it, and I'm sure others will find this useful as well.

    Eden

    Thursday, December 18, 2014 2:54 AM
  • Eden, this is just my small community input :)

    Cheers,
    Marat
    Site: www.scutils.com  Twitter: LinkedIn: Graveyard:

    Thursday, December 18, 2014 4:31 AM