Notification for Activities

Hi,

I have a Change Request form with a set of Activities as show below digram.

I am wonder how I can configure the Notification Templates to display the CR number when the Manual Activity (MA2945) is In Progress.

I have tested that I could have the Notification to display the Parent Activity of MA2945 which in this case it would be SA2944, but i could not get anyway to display the CR which is the parent of SA2944.

Kindly advice.

December 26th, 2013 7:18am

Hi,

I followed this link earlier i got it to display Work Item which is 1 level above.

The condition i have now is 2 level above. This means something like CR -> SA -> MA. and at the MA level, I want the Notification Template to get details from CR.

Thanks.

December 26th, 2013 11:24am

You might want to see if you really need the sequential activity, all activities are processes in a sequential order already. if you remove this (Parent)activity the blog post will allow you to get the SR ID.

If you need to have nested activities I am going to suggest that you look into creating a runbook that will send your notifications, the runbook will allow you to work your way up the relationships to get the SR ID if the nested activities are a requirement. 


Free Windows Admin Tool Kit Click here and download it now
December 30th, 2013 7:08pm

Hi Aries,

yes, it's technically possible to subscribe any property field as long as a relationship exists between the source (the class/projection you specify at the very start when you create the template and subscription). It's just not as easy to do, because you have to make up the relationship path on your own since the "Insert" functionality provided by the GUI is limited in that area.

See my comment on page 2 on the blog post mentioned by MSSQL-DB above to understand what needs to be done in the MP XML. You already figured out how to subscribe the CR ID when using single level activities. I'll try to explain now how to make up the relationship path when using 2nd level or multi level activities:

$Context/Path[Relationship='CustomSystem_WorkItem_Activity_Library!System.WorkItemContainsActivity' SeedRole='Target' TypeConstraint='WorkItem!System.WorkItem']/Property[Type='WorkItem!System.WorkItem']/Id$

This path will work only for single level activities. This is basically because you're telling the workflow engine to look up a the related object by specifying the relationship class. And then when you got the object, you're telling the engine to use the ID field of that related object.

it just know its direct parent object which is the Parallel / Sequentiell Activity. The parent object of the Parallel / Sequentiell Activity now is the CR. This means the manual activity is related to the CR thanks to nested relationships. You just need to make up this nested relationship as the path to actually subscribe them. Visualized the relationship path would look something like this: Manual Activity -> [Contains Activity Relationship] -> Parallel / Sequential Activity -> [Contains Activity Relationship] -> Change Request

Now long story short, this would be the relationship path you have to paste in the notification template for this use case:

$Context/Path[Relationship='CustomSystem_WorkItem_Activity_Library!System.WorkItemContainsActivity' SeedRole='Target' TypeConstraint='WorkItem!System.WorkItem']/Path[Relationship='CustomSystem_WorkItem_Activity_Library!System.WorkItemContainsActivity' SeedRole='Target' TypeConstraint='WorkItem!System.WorkItem']/Property[Type='WorkItem!System.WorkItem']/Id$

I basically just added another relationship layer in this path. The relationship you use in your path of course must exist between the source and the target class, otherwise the path won't work. I recommend to use PowerShell cmdlets to see what's a valid relationship class. See also my other posts in this thread to learn a bit better this technique and how it can be used: http://social.technet.microsoft.com/Forums/en-US/dc498dbe-5e02-4b23-8f2b-6dc32782a25c/notification-on-service-request-instead-of-activity?forum=administration

One last advice: Of course you don't want to create notification templates for each and every Activity combination. And luckily you don't have to :) Just add the relationship path combinations you're using in your environment one by one after another (without spaces). If the path is not resolvable, SCSM will just display a blank output. So this relationship path combination will work regardless if the Manual Activity is a single level or second level activity:

$Context/Path[Relationship='CustomSystem_WorkItem_Activity_Library!System.WorkItemContainsActivity' SeedRole='Target' TypeConstraint='WorkItem!System.WorkItem']/Property[Type='WorkItem!System.WorkItem']/Id$$Context/Path[Relationship='CustomSystem_WorkItem_Activity_Library!System.WorkItemContainsActivity' SeedRole='Target' TypeConstraint='WorkItem!System.WorkItem']/Path[Relationship='CustomSystem_WorkItem_Activity_Library!System.WorkItemContainsActivity' SeedRole='Target' TypeConstraint='WorkItem!System.WorkItem']/Property[Type='WorkItem!System.WorkItem']/Id$

Just go ahead and interpolate with as many level you may use.

Hope this helps and clarifies how to get this done.

Maybe a moderator can pin this thread as I got the impression that these question are popping up quite frequently?!

Happy new year!

BR

Alex

December 30th, 2013 11:01pm

Hi Aries,

yes, it's technically possible to subscribe any property field as long as a relationship exists between the source (the class/projection you specify at the very start when you create the template and subscription). It's just not as easy to do, because you have to make up the relationship path on your own since the "Insert" functionality provided by the GUI is limited in that area.

See my comment on page 2 on the blog post mentioned by MSSQL-DB above to understand what needs to be done in the MP XML. You already figured out how to subscribe the CR ID when using single level activities. I'll try to explain now how to make up the relationship path when using 2nd level or multi level activities:

$Context/Path[Relationship='CustomSystem_WorkItem_Activity_Library!System.WorkItemContainsActivity' SeedRole='Target' TypeConstraint='WorkItem!System.WorkItem']/Property[Type='WorkItem!System.WorkItem']/Id$

This path will work only for single level activities. This is basically because you're telling the workflow engine to look up a the related object by specifying the relationship class. And then when you got the object, you're telling the engine to use the ID field of that related object.

it just know its direct parent object which is the Parallel / Sequentiell Activity. The parent object of the Parallel / Sequentiell Activity now is the CR. This means the manual activity is related to the CR thanks to nested relationships. You just need to make up this nested relationship as the path to actually subscribe them. Visualized the relationship path would look something like this: Manual Activity -> [Contains Activity Relationship] -> Parallel / Sequential Activity -> [Contains Activity Relationship] -> Change Request

Now long story short, this would be the relationship path you have to paste in the notification template for this use case:

$Context/Path[Relationship='CustomSystem_WorkItem_Activity_Library!System.WorkItemContainsActivity' SeedRole='Target' TypeConstraint='WorkItem!System.WorkItem']/Path[Relationship='CustomSystem_WorkItem_Activity_Library!System.WorkItemContainsActivity' SeedRole='Target' TypeConstraint='WorkItem!System.WorkItem']/Property[Type='WorkItem!System.WorkItem']/Id$

I basically just added another relationship layer in this path. The relationship you use in your path of course must exist between the source and the target class, otherwise the path won't work. I recommend to use PowerShell cmdlets to see what's a valid relationship class. See also my other posts in this thread to learn a bit better this technique and how it can be used: http://social.technet.microsoft.com/Forums/en-US/dc498dbe-5e02-4b23-8f2b-6dc32782a25c/notification-on-service-request-instead-of-activity?forum=administration

One last advice: Of course you don't want to create notification templates for each and every Activity combination. And luckily you don't have to :) Just add the relationship path combinations you're using in your environment one by one after another (without spaces). If the path is not resolvable, SCSM will just display a blank output. So this relationship path combination will work regardless if the Manual Activity is a single level or second level activity:

$Context/Path[Relationship='CustomSystem_WorkItem_Activity_Library!System.WorkItemContainsActivity' SeedRole='Target' TypeConstraint='WorkItem!System.WorkItem']/Property[Type='WorkItem!System.WorkItem']/Id$$Context/Path[Relationship='CustomSystem_WorkItem_Activity_Library!System.WorkItemContainsActivity' SeedRole='Target' TypeConstraint='WorkItem!System.WorkItem']/Path[Relationship='CustomSystem_WorkItem_Activity_Library!System.WorkItemContainsActivity' SeedRole='Target' TypeConstraint='WorkItem!System.WorkItem']/Property[Type='WorkItem!System.WorkItem']/Id$

Just go ahead and interpolate with as many level you may use.

Hope this helps and clarifies how to get this done.

Maybe a moderator can pin this thread as I got the impression that these question are popping up quite frequently?!

Happy new year!

BR

Alex

Free Windows Admin Tool Kit Click here and download it now
December 30th, 2013 11:01pm

Hi Aries,

yes, it's technically possible to subscribe any property field as long as a relationship exists between the source (the class/projection you specify at the very start when you create the template and subscription). It's just not as easy to do, because you have to make up the relationship path on your own since the "Insert" functionality provided by the GUI is limited in that area.

See my comment on page 2 on the blog post mentioned by MSSQL-DB above to understand what needs to be done in the MP XML. You already figured out how to subscribe the CR ID when using single level activities. I'll try to explain now how to make up the relationship path when using 2nd level or multi level activities:

$Context/Path[Relationship='CustomSystem_WorkItem_Activity_Library!System.WorkItemContainsActivity' SeedRole='Target' TypeConstraint='WorkItem!System.WorkItem']/Property[Type='WorkItem!System.WorkItem']/Id$

This path will work only for single level activities. This is basically because you're telling the workflow engine to look up a the related object by specifying the relationship class. And then when you got the object, you're telling the engine to use the ID field of that related object.

it just know its direct parent object which is the Parallel / Sequentiell Activity. The parent object of the Parallel / Sequentiell Activity now is the CR. This means the manual activity is related to the CR thanks to nested relationships. You just need to make up this nested relationship as the path to actually subscribe them. Visualized the relationship path would look something like this: Manual Activity -> [Contains Activity Relationship] -> Parallel / Sequential Activity -> [Contains Activity Relationship] -> Change Request

Now long story short, this would be the relationship path you have to paste in the notification template for this use case:

$Context/Path[Relationship='CustomSystem_WorkItem_Activity_Library!System.WorkItemContainsActivity' SeedRole='Target' TypeConstraint='WorkItem!System.WorkItem']/Path[Relationship='CustomSystem_WorkItem_Activity_Library!System.WorkItemContainsActivity' SeedRole='Target' TypeConstraint='WorkItem!System.WorkItem']/Property[Type='WorkItem!System.WorkItem']/Id$

I basically just added another relationship layer in this path. The relationship you use in your path of course must exist between the source and the target class, otherwise the path won't work. I recommend to use PowerShell cmdlets to see what's a valid relationship class. See also my other posts in this thread to learn a bit better this technique and how it can be used: http://social.technet.microsoft.com/Forums/en-US/dc498dbe-5e02-4b23-8f2b-6dc32782a25c/notification-on-service-request-instead-of-activity?forum=administration

One last advice: Of course you don't want to create notification templates for each and every Activity combination. And luckily you don't have to :) Just add the relationship path combinations you're using in your environment one by one after another (without spaces). If the path is not resolvable, SCSM will just display a blank output. So this relationship path combination will work regardless if the Manual Activity is a single level or second level activity:

$Context/Path[Relationship='CustomSystem_WorkItem_Activity_Library!System.WorkItemContainsActivity' SeedRole='Target' TypeConstraint='WorkItem!System.WorkItem']/Property[Type='WorkItem!System.WorkItem']/Id$$Context/Path[Relationship='CustomSystem_WorkItem_Activity_Library!System.WorkItemContainsActivity' SeedRole='Target' TypeConstraint='WorkItem!System.WorkItem']/Path[Relationship='CustomSystem_WorkItem_Activity_Library!System.WorkItemContainsActivity' SeedRole='Target' TypeConstraint='WorkItem!System.WorkItem']/Property[Type='WorkItem!System.WorkItem']/Id$

Just go ahead and interpolate with as many level you may use.

Hope this helps and clarifies how to get this done.

Maybe a moderator can pin this thread as I got the impression that these question are popping up quite frequently?!

Happy new year!

BR

Alex

December 31st, 2013 2:01am

Alex, thank you so much for this solution.  It's working great!  I searched forever for something like this and so I'm very thankful.

I do have one question though.  You say that you can just put the single level code and second level code together.  That does seem to work, but the problem is that any Activity on the second level is picking up both properties, both the Parallel Activity and the Service Request.  I'm only interested in the SR property, can you think of a way I can display only that?  

I don't mind making a second template for second level activities, I just can't figure out a way to setup a Workflow for that so I can have two Workflows, one for the single and one for the second level.

Again, thanks for your help on this.

Free Windows Admin Tool Kit Click here and download it now
January 3rd, 2014 1:09am

Hi Alex,

This is AWESOME !

I got all the point you mentioned and definitely will be trying out over this weekend.

Will let you know if i stumble upon any difficulty.

Thank you so much for sharing with us.

Regards,

Choo Hoong

 

January 3rd, 2014 9:12am

Hi Jeremy,

yes, you're absolutely right. I haven't thought about that when writing my reply and am glad you've mentioned it. Of course both relationship paths are resolvable in my last example, since the MA is a child activity of a parent work item (parallel activity in this case), that's why you get the PA and SR ID displayed in the notification.

When you have a detailed look at the relationship path, you'll find a TypeConstraint part in it. This is nothing different than a filter. In my example I've used TypeConstraint='WorkItem!System.WorkItem' as a filter. Since any Activity and the Service Request class are inherited from the System.WorkItem class, this path becomes resolvable. Now you can modify that to just work for Service Requests if you want. You just change the MP alias to point to the Service Request Library MP and then specify the System.WorkItem.ServiceRequest class. So it would look something like this TypeConstraint='Custom_ServiceRequest_Library!System.WorkItem.ServiceRequest' (make sure the Custom_ServiceRequest_Library alias exists in your MP and points to the Service Request Library MP). Then the path becomes only resolvable when the relationship endpoint is of type System.WorkItem.ServiceRequest.

When you have multiple TypeConstraints in your path, you most likely need to change the very last one to the ServiceRequest class.

The downside of using this is that it won't work now for Manual Activities which are related to Change Requests in the end. You'd have to create another subscription and template for Manual Activities which are related to Change Request. You can do that by creating two queues for Manual Activities (Criteria would be something like Parent Object ID starts with SR and CR)...

Hope this helps.

BR

Alex 


Free Windows Admin Tool Kit Click here and download it now
January 4th, 2014 10:33am

Hi Jeremy,

yes, you're absolutely right. I haven't thought about that when writing my reply and am glad you've mentioned it. Of course both relationship paths are resolvable in my last example, since the MA is a child activity of a parent work item (parallel activity in this case), that's why you get the PA and SR ID displayed in the notification.

When you have a detailed look at the relationship path, you'll find a TypeConstraint part in it. This is nothing different than a filter. In my example I've used TypeConstraint='WorkItem!System.WorkItem' as a filter. Since any Activity and the Service Request class are inherited from the System.WorkItem class, this path becomes resolvable. Now you can modify that to just work for Service Requests if you want. You just change the MP alias to point to the Service Request Library MP and then specify the System.WorkItem.ServiceRequest class. So it would look something like this TypeConstraint='Custom_ServiceRequest_Library!System.WorkItem.ServiceRequest' (make sure the Custom_ServiceRequest_Library alias exists in your MP and points to the Service Request Library MP). Then the path becomes only resolvable when the relationship endpoint is of type System.WorkItem.ServiceRequest.

When you have multiple TypeConstraints in your path, you most likely need to change the very last one to the ServiceRequest class.

The downside of using this is that it won't work now for Manual Activities which are related to Change Requests in the end. You'd have to create another subscription and template for Manual Activities which are related to Change Request. You can do that by creating two queues for Manual Activities (Criteria would be something like Parent Object ID starts with SR and CR)...

Hope this helps.

BR

Alex 


January 4th, 2014 10:33am

Hi Jeremy,

yes, you're absolutely right. I haven't thought about that when writing my reply and am glad you've mentioned it. Of course both relationship paths are resolvable in my last example, since the MA is a child activity of a parent work item (parallel activity in this case), that's why you get the PA and SR ID displayed in the notification.

When you have a detailed look at the relationship path, you'll find a TypeConstraint part in it. This is nothing different than a filter. In my example I've used TypeConstraint='WorkItem!System.WorkItem' as a filter. Since any Activity and the Service Request class are inherited from the System.WorkItem class, this path becomes resolvable. Now you can modify that to just work for Service Requests if you want. You just change the MP alias to point to the Service Request Library MP and then specify the System.WorkItem.ServiceRequest class. So it would look something like this TypeConstraint='Custom_ServiceRequest_Library!System.WorkItem.ServiceRequest' (make sure the Custom_ServiceRequest_Library alias exists in your MP and points to the Service Request Library MP). Then the path becomes only resolvable when the relationship endpoint is of type System.WorkItem.ServiceRequest.

When you have multiple TypeConstraints in your path, you most likely need to change the very last one to the ServiceRequest class.

The downside of using this is that it won't work now for Manual Activities which are related to Change Requests in the end. You'd have to create another subscription and template for Manual Activities which are related to Change Request. You can do that by creating two queues for Manual Activities (Criteria would be something like Parent Object ID starts with SR and CR)...

Hope this helps.

BR

Alex 


Free Windows Admin Tool Kit Click here and download it now
January 4th, 2014 1:33pm

Hi Alex,

Do you have any reference on how I could get the correct MP Alias for TypeConstraint ?

Regards,
Choo Hoong

January 4th, 2014 10:23pm

Hi Alex,

I got this working now. I manage to get the alias by looking into the MP itself.

Thanks again for your great sharing.

Regards,

Choo Hoong

Free Windows Admin Tool Kit Click here and download it now
January 7th, 2014 9:19am

Hi

I've been looking into this in a bit more detail with review activities but can't work out how you would use queues to separate the notification types. From what I can see you have to use the workflow engine to send notifications to reviewers rather than the subscription engine, which doesn't give you options for setting which queue to apply to.

Unless there is a way of defining when the workflow can run based on whether it's parent is a service or change request (or in the 2 level case the grandparent) for use in the workflow engine I can't see how what you've mentioned is possible.

Any ideas would be greatly appreciated.

Thanks

August 4th, 2014 11:32am

Well you can use queues in subscriptions only, when you configure your subscription to work on updates or periodically (not when the objects is being created). It depends on your process obviously when you have to notify a person involved in the process about their activity, but I could imagine to set the subscription trigger when the Review Activity changes its Status from 'NOT In Progress' to 'In Progress'.

you could create two queues for Review Activities where the parent object is a CR and one where the parent is a SR. Then create two subscriptions and select the appropriate queue, you've created before and configure the trigger as mentioned above (Review Activity changes its Status from 'NOT In Progress' to 'In Progress'). Then create a new template for each subscription and select all the variables from your parent object you need.

Hope this helps

Cheers

Alex

Free Windows Admin Tool Kit Click here and download it now
August 6th, 2014 7:42am

Thanks for that Alex, however I don't see how you can create separate queues for review activities with parents that are CR and Parents that are SR. 

I've actually managed to find a way where it doesn't matter what the parent work item is by using what you've mentioned above with the filtering for change requests/service requests as the second item in the list and combined it

$Context/Path[Relationship='CustomSystem_WorkItem_Activity_Library!System.WorkItemContainsActivity' SeedRole='Target' TypeConstraint='CustomSystem_WorkItem_ChangeRequest_Library!System.WorkItem.ChangeRequest']/Property[Type='CustomSystem_WorkItem_Library!System.WorkItem']/Id$$Context/Path[Relationship='CustomSystem_WorkItem_Activity_Library!System.WorkItemContainsActivity' SeedRole='Target' TypeConstraint='CustomSystem_WorkItem_ServiceRequest_Library!System.WorkItem.ServiceRequest']/Property[Type='CustomSystem_WorkItem_Library!System.WorkItem']/Id$$Context/Path[Relationship='CustomSystem_WorkItem_Activity_Library!System.WorkItemContainsActivity' SeedRole='Target' TypeConstraint='CustomSystem_WorkItem_Library!System.WorkItem']/Path[Relationship='CustomSystem_WorkItem_Activity_Library!System.WorkItemContainsActivity' SeedRole='Target' TypeConstraint='CustomSystem_WorkItem_Library!System.WorkItem']/Property[Type='CustomSystem_WorkItem_Library!System.WorkItem']/Id$
This means I can use a single notification template (providing that the generic work item fields only are wanted) for review activities

August 17th, 2014 4:04pm

Where there any changes to SM 2012 R2 that make this invalid. It is exactly the problem I am trying to solve and I can't get it to work.  I tried to cut/paste your solve into a test file and when I run it, I see the code which usually means it doesn't understand something in the code.  I appreciate any help that you give me.
Free Windows Admin Tool Kit Click here and download it now
August 5th, 2015 7:55pm

You can't copy-paste paths into the notification template wizard. You have to type the paths in by hand. Try that and see if it works for you.
August 5th, 2015 8:00pm

I just posted a question on this subject before I found your answer, unfortunately I can seem to get your answer to work.  We are using the same references but when I test it, I get the code back instead of a blank or data which tends to mean the system doesn't like something in the syntax.  Any ideas? 
Free Windows Admin Tool Kit Click here and download it now
August 6th, 2015 12:26pm

So you have to open the management pack directly and change it there?
August 6th, 2015 12:27pm

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics