0

I have a list of column names(64 columns) which needs to be created in SharePoint 2013 Custom List.

When a new list is created these 64 columns needs to created through JSOM or Rest API on one go. Any suggested ways or code can help me on this.

Thank you so much !!

-Dhana

  • Create a content type with that 64 columns, and create a SharePoint custom list from that content type. Instead of creating columns repetitively. Or else we can have site columns if you don't want data. Do you need to create these columns through JSOM only? – Niranjan Kulkarni Jul 12 '18 at 13:04
  • try this column creation with the JSOM [Creating column with JSOM ](sharepoint.stackexchange.com/questions/219522/…) – karthik Jul 12 '18 at 19:45
0

You could add all field Json data in data for Rest API Ajax call like this:

<script type="text/javascript" src="https://code.jquery.com/jquery-3.3.1.js"></script>
<script type="text/javascript">
PostCreateByREST = function (restUrl, data) {
    var result;
    $.ajax({
        url: restUrl,
        async: false,
        type: "POST",
        data: data,
        contentType: "application/json;charset=utf-8;odata=verbose",
        headers: {
            "accept": "application/json;odata=verbose",
            "X-RequestDigest": $("#__REQUESTDIGEST").val(),
            "IF-MATCH": "*",
        },
        success: function (data) {
            console.log(data.d);
            result = true;
        },
        error: function (err) {
            console.log(err);
            result = false;
        }
    });
    return result;
};

var dataFieldCreation = "{ '__metadata': { 'type': 'SP.Field' }, 'FieldTypeKind': 2, 'Title':'testfield'}";
var success = PostCreateByREST("http://sp/sites/dev/_api/Web/Lists/GetByTitle('Dummy')/fields", dataFieldCreation);

</script>

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.