locked
Parent CR data for a Review Activity Notification template RRS feed

  • Question

  • I have a notification email template that will be sent to a reviewer when he/she is assigned a Review Activity when a new CR is created.  The email tells them that they have a Review Activity which they need to complete via the Analyst portal.  The template is called from a Review Activity workflow.

    Unfortunately, I can't figure out how to insert the parent Change Request ID or CR Title into the email template.  All of the property values I try to insert do not produce any values in the email.

    Can anyone suggest which properties I should be inserting into the email template?

    Thanks

     

    Wednesday, December 15, 2010 7:19 PM

Answers

  • //emoMA is your Manaual Activity as EnterpriseManagementObject
    
    //System.WorkItemContainsActivity
    ManagementPackRelationship relRelatesTo =
        emg.EntityTypes.GetRelationshipClass(new Guid("2da498be-0485-b2b2-d520-6ebd1698e61b"));
    
    //Get the parent of the MA
    EnterpriseManagementObject emoParent = null;
    
    foreach (EnterpriseManagementRelationshipObject<EnterpriseManagementObject> objRel in
    emg.EntityObjects.GetRelationshipObjectsWhereTarget<EnterpriseManagementObject>(emoMA.Id, ObjectQueryOptions.Default))
    {
        if (objRel.RelationshipId == relRelatesTo.Id)
        {
            //Get the parent Workitem
            emoParent = objRel.SourceObject;
            break;
        }
    }
    
    if (emoParent != null)
    {
        //Process the parent, you might want to check it's class first
    }

    Monday, March 26, 2012 6:02 PM

All replies

  • The class you choosed for the notification temnplate is Review Activity?

    If so than please expand the Related Class of the Select Property window.

    In the list you should find Depends On Work Item. In the right list you should find ID and Title in the Work Item section.

    Not tested this at the moment, but that should work ... I hope


    Andreas Baumgarten | H&D International Group
    Thursday, December 16, 2010 12:42 PM
  • Thanks Andreas.

    Unfortunately, the Work Item ID and Title Properties in the Depends on Work Item related class didn't produce any results in the email either. 

    The email was sent, but nothing was displayed where the values should have been.

    Chuck

     

    Thursday, December 16, 2010 3:45 PM
  • Try this:

    $Context/Path[Relationship='WorkItem!System.WorkItemRelatesToWorkItem' TypeConstraint='WorkItem!System.WorkItem']/Property[Type='WorkItem!System.WorkItem']/Id$


    http://opsmgr.ru
    Thursday, December 16, 2010 4:01 PM
  • Freeman,

    I tried using the above property and the workflow failed with the following message:

    Cannot resolve identifier WorkItem!System.WorkItemRelatesToWorkItem in the context of management pack ManagementPack.06f40325febf479c8ebb8c1f0cb8fe29. Unknown alias: WorkItem

    Chuck

     

    Thursday, December 16, 2010 4:47 PM
  • look inside of your MP and find References element. Then find the <ID>System.WorkItem.Library</ID> tag and look to Alias above.

    Replace WorkItem! from my string with name of your alias.


    http://opsmgr.ru
    Saturday, December 18, 2010 3:21 PM
  • Hi,

    We have same problem. I tried using the above too and workflow was success.The email was sent but parent ID of RA/MA was not displayed . I tried different class but allways with same result...... :(

    Wednesday, February 16, 2011 1:51 PM
  • I'm just glad other people are having this problem and it isnt just me!

    I've gone as far as creating plain text templates containing all of the available properties, but I cant get the parent change request ID or title to show up. Similarly, in a change request notification, I cant show the notes from a MA or the comments from an RA. Its really frustrating- I rather thought, for instance, Contains Activity/Review Activity/Comments would be pretty self explanatory, but it seems not.

    Steve

    Tuesday, February 22, 2011 1:52 PM
  • Likewise, same problem, very annoying.
    Wednesday, March 9, 2011 5:29 AM
  • We're also having the same issue. I have tried to add every combination of attribute that I can think of but have been unsuccessful in getting parent work items to display in the notifications.
    Thursday, September 22, 2011 6:15 PM
  • You can extend the RA and MA classes with properties like ParentID and ParentTitle. Setup a custom workflow triggered on CR creation that copies the parent CR Id and Title to these properties for each related activity. You can then use these properties in the RA or MA notification template. If you trigger this when the status changes to "in-progress" then the workflow to copy the properties should trigger before the notification workflow.

    At least, this is what I do for this, but, of course, you need to know how to create the custom workflow...

     

    Sunday, September 25, 2011 8:28 PM
  • Rob, I'm working on an activity now to copy the parent CR information to the related activities like you propose.  However, I'm having an issue with getting the activity to identify the Parent CR to copy information from.  Can you offer some advice from your solution?

    Overall, I'm following the code/advice listed on this blog post: http://garydavidson.net/?p=82.  However, "WorkItemID" is not being recognized by Visual Studio as an acceptable parameter and it is requiring me to put a definition for WorkItemID within the script.  I can easily set that as a parameter to be filled by the workflow when built in the Authoring Tool, however since I'm not able to grab parent data in the first place, that's not accomplishing anything, as I'm still stuck without a way of telling the activity what CR to grab the data to populate the ParentProperty fields in my activities with.  How did you manage to identify which CR was the parent CR whose data needed to be copied?

    Monday, March 26, 2012 3:29 PM
  • //emoMA is your Manaual Activity as EnterpriseManagementObject
    
    //System.WorkItemContainsActivity
    ManagementPackRelationship relRelatesTo =
        emg.EntityTypes.GetRelationshipClass(new Guid("2da498be-0485-b2b2-d520-6ebd1698e61b"));
    
    //Get the parent of the MA
    EnterpriseManagementObject emoParent = null;
    
    foreach (EnterpriseManagementRelationshipObject<EnterpriseManagementObject> objRel in
    emg.EntityObjects.GetRelationshipObjectsWhereTarget<EnterpriseManagementObject>(emoMA.Id, ObjectQueryOptions.Default))
    {
        if (objRel.RelationshipId == relRelatesTo.Id)
        {
            //Get the parent Workitem
            emoParent = objRel.SourceObject;
            break;
        }
    }
    
    if (emoParent != null)
    {
        //Process the parent, you might want to check it's class first
    }

    Monday, March 26, 2012 6:02 PM
  • Thanks, Rob, that looks very helpful.  Two questions to make sure I'm on the same page now:

    1) Does that GUID identify System.WorkItemContainsActivity, or is it a variable?  If a variable, what do I need to populate it with?

    2) Regarding "emoMA", I simply need to make that a variable the workflow can populate with the ID of my Activity, correct?

    Thanks!

    Monday, March 26, 2012 6:44 PM
  • 1) Yes, that Guid = System.WorkItemContainsActivity, i.e., it is the Guid of that relationship and will be the same on your system

    2) If you are passing the Id of the MA in question to your workflow then use:

    EnterpriseManagementObject emoMA = emg.EntityObjects.GetObject<EnterpriseManagementObject>(yourpassedMAGuid, ObjectQueryOptions.Default);

    Monday, March 26, 2012 8:55 PM