none
Choice field coming from content type hub cannot be used for grouping in a view RRS feed

  • Question

  • Hello! I am facing an issue and it will be great if someone could help.

    I have a content type hub which replicates columns and content types to all existing site collections. New site collections are being provisioned very often and they have some predefined libraries with views. Some of these views have a grouping configured, one of them is being grouped by a choice field which was created in the content type hub. The view shows wrong data (duplicated), so I tried to manually modify the view and I cannot choose the custom created field coming from the cthub to be able to group. I tried creating a site column in the site collection and it works!. It means that if the field is created in the site where the document library resides it works (I can choose it to group). But if the field comes from CTHub, it does not. Is this the default behaviour? or is it a bug?

    Thanks in advance for the help!

    Friday, March 10, 2017 1:51 PM

All replies

  • Hi Carlos,

    Would you please provide the steps and example data so that we can try to reproduce this issue and find the solution ?

    Thanks

    Best Regards


    Please remember to mark the replies as answers if they help.
    If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com

    Monday, March 13, 2017 6:45 AM
  • Sure, I will try to be as specific as possible.

    1.- I created a site collection to be used as content type hub. We can call it "CTHUB". I created via powershell site columns and site content types in CTHUB to be replicated by the content type subscriber to all other site collections.

    2.- Many of the site columns created are choice fields. Here is an example of the xml used to create the field "BPOwnerStatus" (used $spweb.Fields.AddFieldAsXml to add the field):

    <Field ID="{8FFC605D-16F2-4250-B85A-1E1E0D3A09D8}" Name="BPOwnerStatus" StaticName="BPOwnerStatus" Type="Choice" Format="Dropdown" FillInChoice="FALSE" Group="VARD Build Projects" DisplayName="Owner status" Required="FALSE" Sortable="FALSE" DisplaceOnUpgrade="True">
            <CHOICES>
              <CHOICE>Not sent</CHOICE>
              <CHOICE>Sent for approval</CHOICE>
              <CHOICE>Commented by Owner</CHOICE>
              <CHOICE>Commented by Yard</CHOICE>
              <CHOICE>For re-approval</CHOICE>
              <CHOICE>Approved</CHOICE>
              <CHOICE>Approved w/comments</CHOICE>
              <CHOICE>Rejected w/comments</CHOICE>
            </CHOICES>
            <Default>Not sent</Default>
          </Field>

    3.- Once the field and content types are created, I run the content type subscriber and fields are replicated without issues.

    4.- I create a new site collection by using PnP provisioning, a set of lists/libraries are created. One of them is called "Approval Owner" and the provisioning schema section for the list looks like this:

                            

    <pnp:ListInstance Title="Approval Owner"
                        Description="When ship owners site team do inspections and observations on site. and other inspection remarks"
                        DocumentTemplate=""
                        OnQuickLaunch="true"
                        TemplateType="101"
                        Url="ApprovalOwner"
                        EnableVersioning="true" EnableMinorVersions="true" MinorVersionLimit="2" MaxVersionLimit="0"
                        RemoveExistingContentTypes="true">
              <pnp:ContentTypeBindings>
                <pnp:ContentTypeBinding ContentTypeID="0x0120D520001F4C3071AC895845A4F7995F2EDDCFCC" Default="false"/>
                <pnp:ContentTypeBinding ContentTypeID="0x010100499571EED1945643903B10A898B3FD21" Default="true"/>
                <pnp:ContentTypeBinding ContentTypeID="0x0120D520001F4C3071AC895845A4F7995F2EDDCFCC" Default="false"/>
              </pnp:ContentTypeBindings>
              <pnp:Views>

                <View Name="{3D31CADA-E391-406F-8646-DB58D60C6FA5}" DefaultView="TRUE" MobileView="TRUE" Type="HTML" DisplayName="By status" Url="ApprovalOwner/Forms/By status.aspx" Level="1" BaseViewID="1" ContentTypeID="0x" ImageUrl="/_layouts/15/images/dlicon.png?rev=40">
                  <Query>
                    <GroupBy Collapse="TRUE" GroupLimit="30">
                      <FieldRef Name="BPOwnerStatus" />
                    </GroupBy>
                  </Query>
                  <ViewFields>
                    <FieldRef Name="DocIcon" />
                    <FieldRef Name="LinkFilename" />
                    <FieldRef Name="BPRevision" />
                    <FieldRef Name="APVardResponsible" />
                    <FieldRef Name="BPDueDate" />
                    <FieldRef Name="BPOwnerStatus" />
                  </ViewFields>
                  <RowLimit Paged="TRUE">30</RowLimit>
                  <Aggregations Value="Off" />
                  <JSLink>clienttemplates.js</JSLink>
                </View>            

              </pnp:Views>
            </pnp:ListInstance>

    5.- So far so good, the library is created and the columns are successfully replicated to the newly created site collection. The list gets linked to some content types and the column "BPOwnerStatus" is present. The problem comes in the view provisioned. It is a view grouped by the field "BPOwnerStatus" which is a choice field. The view is shown but the grouping does not work, if I create 2 items in the library each one with a different value in the choice field, the view shows 4 items (the same item duplicated for both status grouped).

    6.- So I tried to manually modify the view and I saw that the grouping was removed from the view configuration, So I had to configure it again. The problem is that the choice field is not shown in the dropdown where you select which field you want to group by.

    7.- I tried creating a site column called "TestChoice" in the site collection (not in cthub) to test with a "local" site column residing in the newly created site collection, and added it to the library to check if I could group by that column, It worked!

    8.- I tried using powershell to check the SchemaXML of both fields and the only difference was that the attributes: EnforceUniqueValues="FALSE" Indexed="FALSE" were present in the "TestChoice" and not in "BPOwnerStatus". So I added them and ran again the content type subscriber job to get the changes, but nothing, same issue again.

    9.- Is it a default behaviour? does it mean that I cannot group by choice fields coming from cthub? I think we should be able to do it.

    I hope this explanation is enough for you to test the scenario and find a possible solution :). Thank you very much in advance!

    Carlos

    Monday, March 13, 2017 11:03 AM
  • Anyone can help? Have anyone tried?
    Tuesday, April 4, 2017 10:57 AM
  • I don't whether it will make a difference, try adding ContentTypesEnabled="true" to the listInstance element.

    <pnp:ListInstance Title="Approval Owner"
                        Description="When ship owners site team do inspections and observations on site. and other inspection remarks"
                        DocumentTemplate=""
                        OnQuickLaunch="true"
                        TemplateType="101"
                        Url="ApprovalOwner"
                        EnableVersioning="true" EnableMinorVersions="true" MinorVersionLimit="2" MaxVersionLimit="0"
                        RemoveExistingContentTypes="true" ContentTypesEnabled="true">

    Also , the contentTypeBindings need one ContentTypeBinding for "0x0120D520001F4C3071AC895845A4F7995F2EDDCFCC"  as below.

    Is the content type "0x010100499571EED1945643903B10A898B3FD21"  set as Default= "true" the one with the choice field "BPOwnerStatus".?

       <pnp:ContentTypeBindings>

                <pnp:ContentTypeBinding ContentTypeID="0x0120D520001F4C3071AC895845A4F7995F2EDDCFCC" Default="false"/>
                <pnp:ContentTypeBinding ContentTypeID="0x010100499571EED1945643903B10A898B3FD21" Default="true"/>
              </pnp:ContentTypeBindings>

    I have created manually a list in a site inheriting content types from a content type hub , bound it with content type having a choice field. The grouping seems to be working fine with a choice field.

    Wednesday, April 5, 2017 10:25 AM