Viewing custom relationships in activities from the parent work item RRS feed

  • Question

  • Hi All

    I found a similar post here, but its an old thread so I'm hoping to get some more help.

    I've added a custom relationship between Work Item and a custom class (based on configuration item), and I've added a single instance picker to all of the work item forms (SR, CR, MA, etc.). When I edit a work item, I can set the value in the single instance picker, and it saves, so everything appears to be working properly. However, if I open an activity from within a parent SR or CR, the data in the single instance picker does not appear. I have to open the activities either directly from an activity view, or by searching for it in order to see the data.

    Per the post linked above, I've added components to the type projection of the form extension for the parent work item for the Work Item Contains Activity relationship, and then my custom relationship nested within that.

    This unfortunately hasn't helped. Am I missing something? Is it possible to make this work so that users who open an activity from within a parent work item can see the contents of a single instance picker on the activity form?


    Wednesday, July 16, 2014 9:58 PM

All replies

  • Could it be that you are opening the activites from a view with a typerpojection that includes this new relationship, but the customized form does not actually target this type projection (and the relation therefore does not show when opening the activity from a SR, CR, etc.)

    If so the fix is trivial. Open the XML that defines your custom form and change the target of the form to point at a type projection that includes the relationship in question.


    Thursday, July 17, 2014 7:48 AM
  • The default parent work item forms use projections that include the full child objects. Essentially you have added a relationship to the SR projection, and to the MA projection, but not to the MA component of the SR projection. you'll need to add your custom relationship to the child objects. here is an example
    <TypeProjection ID="customCRTypeProjection" Accessibility="Public" Type="Change!System.WorkItem.ChangeRequest">
       <Component Path="$Target/Path[Relationship='CustomRequest!System.WorkItemhasCustomizedUser']$" Alias="CustomizedUser" /> <!-- this relationship is for SR to custom -->
       <Component Path="$Target/Path[Relationship='Activity!System.WorkItemContainsActivity']$" Alias="Activity"> <!-- the child activity component -->
          <Component Path="$Target/Path[Relationship='WorkItem!System.WorkItemCreatedByUser']$" Alias="ActivityCreatedBy" /> <!-- part of the child activity -->
          <Component Path="$Target/Path[Relationship='CustomRequest!System.WorkItemhasCustomizedUser']$" Alias="CustomizedUser" /> <!-- this relationship is for MA to custom -->
          <!-- not interesting bits snipped... -->
       <!-- not interesting bits snipped... -->

    • Edited by Thomas Bianco Thursday, July 17, 2014 2:32 PM readability
    Thursday, July 17, 2014 2:30 PM
  • quoting the original post: However, if I open an activity from within a parent SR or CR, the data in the single instance picker does not appear. 

    He is not trying to bind the single instance picker to a relationship in a "child" work item. If he was you are absolutely spot on with the nested type projection.


    Thursday, July 17, 2014 5:28 PM
  • yes, he's opening a parent work item, then opening a child activity from within that form. Because of the way that the console caches data, the child activity's form is populated from the in-memory projection of the parent form. In the same way, changes that you make in that child activity form are written back to the in-memory projection of the parent form. You can verify this by opening a SR, opening a child activity, making a bunch of changes to the activity and clicking OK on the activity form, and then clicking cancel on the SR form. none of the activity changes will be saved to the database.

    essentially, what's happening is like this:

    Friday, July 18, 2014 2:46 PM
  • So if I have a custom relationship on a manual activity that is contained within a parallel activity, that is contained within a sequential activity, that is contained within another parallel activity,.... many more activity containers....., that is contained within a service request, then the service request projection must target a deep deep deep (even deeper) deeply nested type projection?


    Friday, July 18, 2014 3:35 PM
  • Technically - yes, you need to have nested components. Your next question will be "but how it's work with activities for instance???". The answer is simple - it's hardcoded. Each time when you open the form code behind check if activities is here and merge type projections if necessary.

    So the only solution for subject is create custom control and merge projection with it.

    email: freemanru (at) gmail (dot) com

    Sunday, July 20, 2014 8:26 PM
  • as Anton points out here and as Aaron pointed out to me in my first post the default activity forms "cheat" by calling FetchAndMergeSubProjection() as part of the form code behind to expand the in-memory projection with the contents of other projections, essentially creating a 19-story building out of two 10-story buildings by adding the second building as the 9th floor of the first building.

    That is perhaps the most hacky analogy ever made.

    This is pure speculation, but what about creating an MP that overrides the default activity form projections? the same technique Anton detailed here might apply to the projection definition, thou I have never used it for this type of thing.

    This is far more advanced MP manipulation, and I have never tried to replace a projection before, so YMMV, but it might work. rather then merging the default form projection, the code-behind that we're talking about would instead merge your updated projection.  

    • Edited by Thomas Bianco Monday, July 21, 2014 1:53 PM clarification of terms and possible solution
    Monday, July 21, 2014 1:46 PM
  • @Thomas, this is not possible. But you can create your own type projection and your own form definition but use the same OOB assembly.

    email: freemanru (at) gmail (dot) com

    Monday, July 21, 2014 5:22 PM
  • Eh, it was worth a shot.

    Monday, July 21, 2014 5:47 PM
  • Sorry for the delay. I did originally have the nested components in the type projection, but that didn't work. Based on Anton's comments, it looks like i'll need to build a custom form definition. I'll give this a try next and see if I can get anywhere. Thanks.
    Wednesday, August 6, 2014 2:01 PM
  • I have also not been able to get something similar to work with a nested type projection as suggested by Aaron in the link.

    I actually got a weird bug in stead where request offering mappings to underlying activites stopped working when submitted from the portal - read more here.


    Wednesday, August 6, 2014 2:04 PM