How to update views to change the criteria from “Assigned to me” to “Assigned to me or a group that I belong to”

How to update views to change the criteria from “Assigned to me” to “Assigned to me or a group that I belong to”

  • Comments 9
  • Likes

Our out of the box views contain a few views like “Change Requests: Assigned to Me”, “Activities Assigned to Me”, “My Incidents” etc. These views only display objects where the criteria match the current user. You can update these views or create new views where you would want the criteria to match the current user or a group the current user belongs to.

There is a way to do this in the management pack. The UI currently does not support this. So you will have to update the management pack xml.

1.  Export the Management Pack that contains the view you want to update. To do this, In the Service Manager console, Go to the Administration->Management Packs view, Select the unsealed management pack and click Export in the task pane. For more information on exporting management packs see Hacking Management Pack XML Like a Pro.

2.  Make a backup of the Management Pack in case you need to go back.

3.  I will use the ChangeManagement.Views.ChangeRequestsAssignedToMe view as an example here.

4.  Open the Management Pack in the editor and find the <Criteria> tag in the View that you want to update.

5.  Under the criteria look for the expression

<Expression>

  <SimpleExpression>

    <ValueExpressionLeft>

      <GenericProperty Path="$Context/Path[Relationship='WorkItem!System.WorkItemAssignedToUser' SeedRole='Source']$">Id</GenericProperty>                         

    </ValueExpressionLeft>

    <Operator>Equal</Operator>

    <ValueExpressionRight>

      <Token>[me]</Token>

    </ValueExpressionRight>

  </SimpleExpression>

</Expression>

6.  Replace the above expression with

<Expression>

  <In>

    <GenericProperty Path="$Context/Path[Relationship='WorkItem!System.WorkItemAssignedToUser' SeedRole='Source']$">Id</GenericProperty>

    <Values>

      <Token>[me]</Token>

      <Token>[mygroups]</Token>

    </Values>

  </In>

</Expression>

PS. For other views make sure the Path in the replaced xml matches the Path in the original xml.

7.       Save and import the MP.

Your comment has been posted.   Close
Thank you, your comment requires moderation so it may take a while to appear.   Close
Leave a Comment
  • I can't seem to get the "mygroups" token to work, it's almost as if the "mygroups" doesn't exist. I have tried subing the "mygroups" token for the "me" token and it doesn't run the query after importing the MP. I am editing the system.workitem.incident.assignedtome view  Below is a sample of the code. Also, I should mention that this is a test environment, so we can evaluate Service Manager against our current solution. What am I missing?

    <View ID="System.WorkItem.Incident.AssignedToMe.View" Accessibility="Public" Enabled="true" Target="CoreIncident!System.WorkItem.Incident" TypeID="SMConsole!GridViewType" Visible="true">

           <Category>NotUsed</Category>

           <Data>

             <Adapters>

               <Adapter AdapterName="dataportal:EnterpriseManagementObjectProjectionAdapter">

                 <AdapterAssembly>Microsoft.EnterpriseManagement.UI.SdkDataAccess</AdapterAssembly>

                 <AdapterType>Microsoft.EnterpriseManagement.UI.SdkDataAccess.DataAdapters.EnterpriseManagementObjectProjectionAdapter</AdapterType>

               </Adapter>

               <Adapter AdapterName="viewframework://Adapters/AdvancedList">

                 <AdapterAssembly>Microsoft.EnterpriseManagement.UI.ViewFramework</AdapterAssembly>

                 <AdapterType>Microsoft.EnterpriseManagement.UI.ViewFramework.AdvancedListSupportAdapter</AdapterType>

               </Adapter>

             </Adapters>

             <ItemsSource>

               <AdvancedListSupportClass DataTypeName="" AdapterName="viewframework://Adapters/AdvancedList" FullUpdateAdapter="dataportal:EnterpriseManagementObjectProjectionAdapter" RemoveItemsAdapter="dataportal:EnterpriseManagementObjectProjectionAdapter" AppendItemsAdapter="dataportal:EnterpriseManagementObjectProjectionAdapter" UpdateItemsAdapter="dataportal:EnterpriseManagementObjectProjectionAdapter" DataSource="mom:ManagementGroup" FullUpdateFrequency="100" Streaming="true" IsRecurring="True" RecurrenceFrequency="30000" xmlns="clr-namespace:Microsoft.EnterpriseManagement.UI.ViewFramework;assembly=Microsoft.EnterpriseManagement.UI.ViewFramework" xmlns:av="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib">

                 <AdvancedListSupportClass.Parameters>

                   <QueryParameter Parameter="TypeProjectionId" Value="$MPElement[Name='System.WorkItem.Incident.View.ProjectionType']$" />

                 </AdvancedListSupportClass.Parameters>

               </AdvancedListSupportClass>

             </ItemsSource>

             <Criteria>

               <QueryCriteria Adapter="omsdk://Adapters/Criteria" xmlns="http://tempuri.org/Criteria.xsd">

                 <Criteria>

                   <FreeformCriteria>

                     <Freeform>

                       <Criteria xmlns="http://Microsoft.EnterpriseManagement.Core.Criteria/">

                         <Expression>

    <In>

                             <GenericProperty       Path="$Context/Path[Relationship='WorkItem!System.WorkItemAssignedToUser']$">Id</GenericProperty>

                             <Values>

                               <Token>[me]</Token>

                               <Token>[mygroups]</Token>

                             </Values>

                           </In>

                         </Expression>

                       </Criteria>

                     </Freeform>

                   </FreeformCriteria>

                 </Criteria>

               </QueryCriteria>

             </Criteria>

           </Data>

    Thanks for any insight you can provide.

  • Does the Out of box view work as expected? Have you imported the users and groups using the AD connector?

    If you have all the users in the system, then assign the user to a group. Login as a user in the group and you should see the incident in the view.

    When you say the view does not work, does it show any error or just not show the items you expect to be there.

  • Yes, the out of box view for viewing IR's assigned to me. Users and groups have been imported from AD using the connector. I am assigned to one of the groups and when logged in as me, I only see what is assigned to me and not my groups. After updating the management pack with the "mygroups" token, if I look at the view in the work items UI, the criteria has red asterik next to it but it still sees work items assigned to me just not mygroups.

    There are no errors of any kind.

  • Can you please email your mp containing the view to scsmbeta@live.com

  • I'm having the same problem. Was there a solution to this?

  • This worked for me. I followed the EXACT steps as above. You do not need to update the view and add [mygroups] to the view query. IT seems the MP XML file change does that automatically and links the [my groups] automatically. However, Here is the issue I ran into. The view when opened shows the work items assigned to me and my groups. But the pane appears to be frozen. I can not scroll up nor down. I can filter and select work items that I can see on the pane, but I can not see all the fields due to it not letting me scroll left, right, up, or down. Weird.

  • Ok, if you increase  the size of the window pains it works to see all the work items. But does not let me use the scroll bars when the window is smaller. Very weird. But the view is now working as I wanted it.

  • Disregard window pane scrolling issues. That was unrelated to this.

    The fix worked. The key is make sure to save the MP as a .xml file after you switch the code out. Also, make sure to import it back in. And then do NOT make any modifications to the view criteria for "...Assigned to me" views.

    Good Luck

  • Hi there.

    Is it possible to do this kind of customization for custom class properties?

    For example, I've added Relationship to Active Directory Group

    <RelationshipType ID="IncidentToAssignmentGroup" Accessibility="Public" Abstract="false" Base="System!System.Reference">

       <Source ID="Source_IncidentToAssignmentGroup" Type="Incident!System.WorkItem.Incident" />

       <Target ID="Target_IncidentToAssignmentGroup" Type="Windows!Microsoft.AD.Group" />

    </RelationshipType>

    ...

    <TypeProjection ID="Custom_TypeProjection" Accessibility="Public" Type="Inicdent!System.WorkItem.Incident">

       <Component Path="$Context/Path[Relationship='IncidentToAssignmentGroup']$" Alias="Component_12345">

    </TypeProjection>

    and want to display those Incideтt Tickets where populated Assignment Group contains current user.

    What should I write as a path for GenericProperty tag?

    Thanks in advance.