Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

I have a solution in which one of the features defines a collection of External Content Types. The solution also has a feature that creates an External List Instance for accessing one of the ECTs. Because I wanted to define a few default views (with a select list of columns) I added a Schema.xml file to the feature and CustomSchema attribute to the ListInstance.

However, the addition of the CustomSchema attribute seems to break the OnQuickLaunch in that the Quick Launch link is not created. Here is my code

Elements.xml

<?xml version="1.0" encoding="utf-8"?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
    <ListInstance TemplateType="600"
                  Title="My List"
                  OnQuickLaunch="TRUE"
                  Url="Lists/MyList"
                  CustomSchema="MyList\Schema.xml"
                  xmlns="http://schemas.microsoft.com/sharepoint/">
        <DataSource>
            <Property Name="LobSystemInstance" Value="MyECT" />
            <Property Name="EntityNamespace" Value="IOC.BCS.MyConnectModel" />
            <Property Name="Entity" Value="CI" />
            <Property Name="SpecificFinder" Value="GetIndById" />
        </DataSource>
    </ListInstance>
</Elements>

If I use the above, the list is created but not added to the Quick Launch. If I remove the CustomSchema attribute, the list is created and added to the Quick Launch but obviously I loss my custom views.

share|improve this question
add comment

2 Answers

enter image description hereI always use TYPE binding as in (of course there is Schema.xml too - is simple with Visual Studio 2010):

 <ListTemplate 
    Name="FAQ" 
    Type="10001" 
    BaseType="0" 
    OnQuickLaunch="FALSE" 
    SecurityBits="11"
    Category="Libraries"
    DisableAttachments="TRUE"
    AllowEveryoneViewItems="TRUE"
    EnableModeration="True"
    VersioningEnabled="FALSE"
    Sequence="320"
    DisplayName="FAQ"
    Description="Create a new FAQ"
    Image="/_layouts/images/itann.png"/>

and then your instance could be <ListInstance Title="Frequently Asked Questions" OnQuickLaunch="FALSE" VersioningEnabled="FALSE" TemplateType="10001" Url="FAQ" Description="Use this list to create and store FAQs.">

share|improve this answer
    
Can you expand your explanation please? Are you suggesting that instead of using a Schema I should define the list using the ListTemplate instead? I guess your intention is to remove the need for the Schema.xml file thus fixing the OnQuickLaunch issue. Does the ListTemplate allow me to define views? What is the difference between the ListTemplate and Schema? –  Jason Apr 23 '12 at 16:46
    
In your solution use VS2010 and add List Definition (chose an existing template or base it on Content types). At one moment you can check whether you want also List instance. As a result, should contain 2 files for the List definition & 2 files for the listInstance. It is important for the List definition to work properly, and then you can use the ListInstance with TYPE to have it work (see edit image). –  C. Marius - MVP Apr 23 '12 at 18:12
    
Ah, that clears it out (sorry, I've missed it from your initial text - dumb of me)! External Lists cannot be created using declarative methods, mainly because you need to specify and ECT which is bound to the list. Try using a Feature Receiver or something similar to create it programatically. –  C. Marius - MVP Apr 24 '12 at 16:49
    
Thanks for the attempt. I actually can create the instance declaratively...it is just that some settings in the elements file are ignored. –  Jason Apr 27 '12 at 5:57
add comment

Somehow, this is not possible OOB. A way to handle the problem is shown in this Microsoft Tutorial.

Add a class with the following code to your project.

using Microsoft.SharePoint;

class Customizations
{
    private string[] externalListTitles = null;

    public Customizations(string[] listTitles)
    {
        externalListTitles = listTitles;
    }

    public void Activate(SPWeb spWeb)
    {
        if (externalListTitles != null)
        {
            MakeExternalListsVisibleOnQuickLaunch(spWeb);
        }
    }

    private void MakeExternalListsVisibleOnQuickLaunch(SPWeb spWeb)
    {
        for (int i = 0; i < externalListTitles.Length; i++)
        {
            SPList externalList = spWeb.Lists.TryGetList(externalListTitles[i]);
            if (externalList != null)
            {
                externalList.OnQuickLaunch = true;
                externalList.Update();
            }
        }
    }

}

Then, add a feature event receiver to the feature which contains your list and add the following code:

private string[] externalListTitles = { "YourList" };

    public override void FeatureActivated(SPFeatureReceiverProperties properties)
    {
        base.FeatureActivated(properties);

        SPWeb spWeb = (SPWeb)properties.Feature.Parent;

        // Enable list customizations.
        Customizations customizations = new Customizations(externalListTitles);
        customizations.Activate(spWeb);
    }
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.