I searched everywhere, but could not find a solution that worked for me.

We've created a default survey, changed it a bit and saved it as a new ESS Survey template from the user interface. I can create surveys based on this template successfully.

However, I have some C# code that creates a survey name automatically for me. It is now based on the template ID is "102", which is the default survey. I want to create the survey in code based on my custom survey.

I understood that I need a custom list template ID (which should be > 10000), but I cannot find out how I can find the custom list template id's. I found commands that list the default list template id's (i.e. 100, 101) but not the custom survey template ID's. How can I find the custom surveytemplate ID's?


I don't know if you can check a list by ID, but you can check the "BaseTemplate" property.

SPList list = web.Lists["List ID"];
    SPListTemplateType type = list.BaseTemplate;

    if(type == SPListTemplateType.Tasks){
    //Do something for a Task List
    }else if(type == SPListTemplateType.Survey)
    //Do something for a Survey List

If this solution don't solve your problem, this is a walkaround:

First, you have to change your list creation code, adding a property bag to them. This will be a "flag" to check if is a custom survey list:

After create the new list, do this:

 list.RootFolder.Properties.Add("CustomListCheck", true);

Now, checking the list:

bool isCustom = list.RootFolder.Properties["CustomListCheck"];
 if(isCustom == true){
  //Do something...
| improve this answer | |

You should be able to get it using Object-Model-Browsers like SharePoint-Manager 2013 (available via Codeplex)

But I don´t know, if your list gets a custom templateId at all, if you are generating your template using the "Save As Template"-Option via the GUI. If it does, however, the base List, from which you generated the template will still have it´s original, built-in ID. Only new Lists would get the new BaseTemplateID

Besides: Maybe you should consider deploying a Template with fixed ID using a Feature. Because if you Change something in your base-List and generate a new Template, it will (if it does so) get a new templateId. And then you might have to Change your code again.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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