none
Localized view name issue when create list programmatically in Visual Studio using SPListCollection.Add method RRS feed

  • Question

  • Hello!

    I try to create new List in "FeatureActivated" Event Receiver. For this I use SPListCollection.Add method (String, String, String, String, Int32, String, String, SPFeatureDefinition, SPListTemplate.QuickLaunchOptions).

    My code below:

    public override void FeatureActivated(SPFeatureReceiverProperties properties)
    {
        using (SPWeb rootWeb = properties.Feature.Parent as SPWeb)
        {
            try
            {
                SPFeatureDefinition spfd = SPFarm.Local.FeatureDefinitions[new Guid("00BFEA71-DE22-43B2-A848-C05709900100")];
                string xmlList = "<?xml version='1.0' encoding='utf-8'?> <List xmlns:ows='Microsoft SharePoint' Title='Basic List' FolderCreation='FALSE' Direction='$Resources:Direction;' Url='Lists/Basic List' BaseType='0'> <MetaData> <ContentTypes> <ContentTypeRef ID='0x01'> <Folder TargetName='Item' /> </ContentTypeRef> <ContentTypeRef ID='0x0120' /> </ContentTypes> <Fields> </Fields> <Views> <View BaseViewID='0' Type='HTML' MobileView='TRUE' TabularView='FALSE'> <XslLink Default='TRUE'>main.xsl</XslLink> <RowLimit Paged='TRUE'>30</RowLimit> <Toolbar Position='After' Type='Freeform' /> <RowLimit>20</RowLimit> <ViewFields> <FieldRef Name='LinkTitleNoMenu'> </FieldRef> </ViewFields> <Query> <OrderBy> <FieldRef Name='Modified' Ascending='FALSE'> </FieldRef> </OrderBy> </Query> <ParameterBindings> <ParameterBinding Name='AddNewAnnouncement' Location='Resource(wss,addnewitem)' /> <ParameterBinding Name='NoAnnouncements' Location='Resource(wss,noXinviewofY_LIST)' /> <ParameterBinding Name='NoAnnouncementsHowTo' Location='Resource(wss,noXinviewofY_ONET_HOME)' /> </ParameterBindings> </View> <View BaseViewID='1' Type='HTML' WebPartZoneID='Main' DisplayName='$Resources:core,objectiv_schema_mwsidcamlidC24;' DefaultView='TRUE' MobileView='TRUE' MobileDefaultView='TRUE' SetupPath='pages\viewpage.aspx' ImageUrl='/_layouts/images/generic.png' Url='AllItems.aspx'> <XslLink Default='TRUE'>main.xsl</XslLink> <RowLimit Paged='TRUE'>30</RowLimit> <Toolbar Type='Standard' /> <ViewFields> <FieldRef Name='Attachments'> </FieldRef> <FieldRef Name='LinkTitle'> </FieldRef> </ViewFields> <Query> <OrderBy> <FieldRef Name='ID'> </FieldRef> </OrderBy> </Query> <ParameterBindings> <ParameterBinding Name='NoAnnouncements' Location='Resource(wss,noXinviewofY_LIST)' /> <ParameterBinding Name='NoAnnouncementsHowTo' Location='Resource(wss,noXinviewofY_DEFAULT)' /> </ParameterBindings> </View> </Views> <Forms> <Form Type='DisplayForm' Url='DispForm.aspx' SetupPath='pages\form.aspx' WebPartZoneID='Main' /> <Form Type='EditForm' Url='EditForm.aspx' SetupPath='pages\form.aspx' WebPartZoneID='Main' /> <Form Type='NewForm' Url='NewForm.aspx' SetupPath='pages\form.aspx' WebPartZoneID='Main' /> </Forms> </MetaData> </List>";
                rootWeb.Lists.Add("Test1", "Test", "Lists/Test", "00BFEA71-DE22-43B2-A848-C05709900100", 100, "100", xmlList, spfd, SPListTemplate.QuickLaunchOptions.Off);
                rootWeb.Dispose();
            }
            catch (Exception e)
            {
                Console.WriteLine("Error: " + e.ToString());
            }
        }
                
    }

    xmlList is string variable of default CustomList Feature XML Schema:

    <?xml version="1.0" encoding="utf-8"?>
    <List xmlns:ows="Microsoft SharePoint" Title="Basic List" FolderCreation="FALSE" Direction="$Resources:Direction;" Url="Lists/Basic List" BaseType="0">
      <MetaData>
        <ContentTypes>
          <ContentTypeRef ID="0x01">
            <Folder TargetName="Item" />
          </ContentTypeRef>
          <ContentTypeRef ID="0x0120" />
        </ContentTypes>
        <Fields>
        </Fields>
        <Views>
          <View BaseViewID="0" Type="HTML" MobileView="TRUE" TabularView="FALSE">
            <XslLink Default="TRUE">main.xsl</XslLink>
            <RowLimit Paged="TRUE">30</RowLimit>
            <Toolbar Position="After" Type="Freeform" />
            <RowLimit>20</RowLimit>
            <ViewFields>
              <FieldRef Name="LinkTitleNoMenu">
              </FieldRef>
            </ViewFields>
            <Query>
              <OrderBy>
                <FieldRef Name="Modified" Ascending="FALSE">
                </FieldRef>
              </OrderBy>
            </Query>
            <ParameterBindings>
              <ParameterBinding Name="AddNewAnnouncement" Location="Resource(wss,addnewitem)" />
              <ParameterBinding Name="NoAnnouncements" Location="Resource(wss,noXinviewofY_LIST)" />
              <ParameterBinding Name="NoAnnouncementsHowTo" Location="Resource(wss,noXinviewofY_ONET_HOME)" />
            </ParameterBindings>
          </View>
          <View BaseViewID="1" Type="HTML" WebPartZoneID="Main" DisplayName="$Resources:core,objectiv_schema_mwsidcamlidC24;" DefaultView="TRUE" MobileView="TRUE" MobileDefaultView="TRUE" SetupPath="pages\\viewpage.aspx" ImageUrl="/_layouts/images/generic.png" Url="AllItems.aspx">
            <XslLink Default="TRUE">main.xsl</XslLink>
            <RowLimit Paged="TRUE">30</RowLimit>
            <Toolbar Type="Standard" />
            <ViewFields>
              <FieldRef Name="Attachments">
              </FieldRef>
              <FieldRef Name="LinkTitle">
              </FieldRef>
            </ViewFields>
            <Query>
              <OrderBy>
                <FieldRef Name="ID">
                </FieldRef>
              </OrderBy>
            </Query>
            <ParameterBindings>
              <ParameterBinding Name="NoAnnouncements" Location="Resource(wss,noXinviewofY_LIST)" />
              <ParameterBinding Name="NoAnnouncementsHowTo" Location="Resource(wss,noXinviewofY_DEFAULT)" />
            </ParameterBindings>
          </View>
        </Views>
        <Forms>
          <Form Type="DisplayForm" Url="DispForm.aspx" SetupPath="pages\\form.aspx" WebPartZoneID="Main" />
          <Form Type="EditForm" Url="EditForm.aspx" SetupPath="pages\\form.aspx" WebPartZoneID="Main" />
          <Form Type="NewForm" Url="NewForm.aspx" SetupPath="pages\\form.aspx" WebPartZoneID="Main" />
        </Forms>
      </MetaData>
    </List>

    After activate feature list created successfully. And all elements in this list are localized, except View Name. I use ru-RU and en-US languages in my farm. It seems that "DisplayName="$Resources:core,objectiv_schema_mwsidcamlidC24;" in XML string applied, but not properly, so View Name displayed only in Russian even I change language to English.

    Please help. What I'm doing wrong?

    Issue Image

    Thursday, March 30, 2017 6:47 AM

All replies

  • Hi Ivan,

    Just a quick note that I’m working on this currently, I will come back once there is any progress.

    Best regards,

    Patrick 

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

    Wednesday, April 5, 2017 1:47 AM
    Moderator