Tell me more ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

Im trying to create a list by using the JavaScript CSOM, but Im stuck at a certain point.

In this example I use the Template "SP.ListTemplateType.issueTracking" to create and enhance a list, in this list is a standard choice-column "category" with the default-values "category 1", "category 2", "category 3".

Id like to replace these choice-values with "General", "Bug-Report" and "Requirement".

function CreateList_Tickets(){
    var context = new SP.ClientContext();
    var web = context.get_web();
    var listCreationInfo = new SP.ListCreationInformation();
    listCreationInfo.set_title('My_Tickets');
    listCreationInfo.set_templateType(SP.ListTemplateType.issueTracking);
    newList = web.get_lists().add(listCreationInfo);
    context.load(newList);
    var LocationOfCreationXML = '<Field DisplayName="LocationOfCreation" Type="Text"/>';
    newList.get_fields().addFieldAsXml(LocationOfCreationXML,true,SP.AddFieldOptions.defaultValue);
    newList.update();
    context.executeQueryAsync(success,failure);
}

function success(sender,args){
    alert("New list created - Title:" + newList.get_title()+" - List-ID:"+newList.get_id());
}
function failure(sender,args){
    alert("Creation failed - Message:"+args.get_message());
}

Any idea how to solve that?

Ive tried to simply override the column and choice-values, but that isnt working, sharepoint automatically adds a random number to the column-title without touching the original column.

this is how i tried it:

var CategoryXml ='<Field DisplayName="Kategorie" Type="Choice"><CHOICES>   <CHOICE>General</CHOICE><CHOICE>Bug-Report</CHOICE><CHOICE>Requirement</CHOICE></CHOICES></Field>';
newList.get_fields().addFieldAsXml(CategoryXml,true,SP.AddFieldOptions.defaultValue);
share|improve this question

Know someone who can answer? Share a link to this question via email, Google+, Twitter, or Facebook.

Your Answer

 
discard

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

Browse other questions tagged or ask your own question.