In SharePoint, what is the easiest way to create a custom list 'schema.xml' file?

592

Solution 1

To create custom list definition I always use some built in list definition as template.
Create new feature then copy schema.xml (maybe some other files also if present) from existing feature and modify schema.xml file directly with some text editor. I don’t have tried any custom editor for that and always get work done with copy-paste and changing attributes values.

Built in list definitions are located in 12 hive as features:

  • Custom List – Features/CustomList/CustList/schema.xml;
  • Document Library – Features/DocumentLibrary/DocLib/schema.xml;
  • Calendar – Feature/EventsList/Events/schema.xml;
  • Use search to find others.

Solution 2

My recommendation, and what will bring you the closest to a final version, is to use the SharePoint web interface, set up your list as you want it, including views, custom columns, etc. Then, save the list as a template.

The .stp file you get is basically just a .cab file with a funny name. Rename to cab and extract the manifest, which will include a nearly ready-to-use schema.xml file for you to use.

What you need to change is the path or setuppath of the list forms. You will find these at the bottom of the manifest.xml file. These forms, if you use the default SharePoint lists, can be set to SetupPath="pages/form.aspx". Here is an example from the custom list forms element:

    <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" />

You also need to update the View path for every view, which should be SetupPath="pages/viewpage.aspx" if using the default forms in your original site.

Note that you need to modify other attributes as well, but if you make sure to follow the wss.xsd schema and that your custom list schema.xml validates to the wss.xsd schema you should be ok.

.b

Solution 3

With the Windows SharePoint Services 3.0 Tools: Visual Studio 2008 Extensions, Version 1.2 comes an application called "SharePoint Solution Generator 2008". This application has some restrictions (the worst is IMO that lookup columns disappear), but it creates the files you need to create i.e. a feature out of an existing SharePoint-List. This includes the schema.xml.

Solution 4

I always use Gary Lapointes STSADM extensions for extracting that kind of stuff. That is, I create it first using the GUI and then extract lists, content types, site columns, etc. using the appropriate method.

Check out Garys list of extensions in STSADM/PowerShell Commands.

Solution 5

You could use SharePoint manager to select the list you want the schema for and use that as a template.

Any schema generation would rely on context as the GUIDs for any custom fields will be specific to that SharePoint site collection unless they are installed as part of a previously specified feature (relying on an XML schema having been created already).

SharePoint manager is a good tool for this not because it is specific to this problem, but because it is a very useful way of getting all sorts of information (like schema) out of a SharePoint instance.

Share:
592
the_islander
Author by

the_islander

Updated on June 04, 2022

Comments

  • the_islander
    the_islander almost 2 years

    I'm trying to get values from a HTML select input to my controller so that I can use it in a conditional erb snippet

    This is the html snippet for the dropdown

    <select id="select" name="parish" class="form-control" onchange="choice(this.value)">
      <option value="">--Select value--</option>
      <option value="test">test</option>
      <option value="two">2</option> 
    </select>
    

    I was told to use AJAX to pass the value

    function choice(value) {
      console.log(value)
      $.ajax({
        url: '/tickets/index',
        type: 'GET',
        data: {
          parish: $('#select').val()
        }
        /*success:function() {
          body...
        }*/
      })
    }
    

    And my ticket controller looks like this:

    def index
        @ticket = Ticket.all;
        @value = params[:parish]
        puts @value
    end
    

    This is the conditional erb, as you can see it is set up to use the variable from the controller but it doesn't work, but if I replace @value with a hardcoded string it works, puts @value displays the value in the console so it isn't empty. What am I doing wrong?

     <% @ticket.where(parish: @value).each do |ticket| %>
    
    • Gerry
      Gerry almost 7 years
      Do you get any error messages in your log?
    • the_islander
      the_islander almost 7 years
      @Gerry no errors, just seeing the variable being printed
    • the_islander
      the_islander almost 7 years
      I know, I was under the impression that GET puts the key value pair in the url and params in the controller takes the variables from the URL
    • Pavan
      Pavan almost 7 years
      Try changing <% @ticket.where(parish: @value).each do |ticket| %> to <% Ticket.where(parish: @value).each do |ticket| %>
  • Philidor
    Philidor almost 7 years
    You can't send a data with GET request, only with POST.
  • the_islander
    the_islander almost 7 years
    Thanks but it still doesn't work, I am getting a better result, previously the map would move to the middle of the sea with 0 markers, when I select a parish it just kinda refreshes and shows all markers still so not working like when hardcoded
  • Pavan
    Pavan almost 7 years
    @the_islander What is the value of parish in the params look like?
  • the_islander
    the_islander almost 7 years
    puts params[:parish] prints kingston when I select that from the dropdown which should work as the string "kingston" works. I compared the SQL statement the variable and hardcoded string produces and they are the same so this is weird