4

Isn't it possible to update created and modified like the following method?

This works for other column properties but nothing happens in modified and created column.

var body = "{ '__metadata': {'type':'SP.ListItem'},'Modified':'2012-03-30T17:24:17Z'}";

var json = client.UploadString(url, body);
3

Ideally, It's not possible. But There is workaround for that. Basically, Created and Modified columns are ReadOnly columns.

So, We need to modify list schema to make these available for modification (set ReadOnly attribute to false) as shown below for Created field.

var updateCreatedDate = "<Fields>" + 
"<Method ID='1'><Field ID='{8c06beca-0777-48f7-91c7-6da68bc07b69}' ColName='tp_Created' RowOrdinal='0' ReadOnly='FALSE' Type='DateTime' Name='Created' DisplayName='Created' StorageTZ='TRUE' SourceID='http://schemas.microsoft.com/sharepoint/v3' StaticName='Created' FromBaseType='TRUE' Version='4' ShowInNewForm='FALSE' ShowInEditForm='FALSE' /></Method>" +
"</Fields>";
        $().SPServices({
          operation: "UpdateList",
          listName: "Events",
          listProperties:"",
          updateFields: updateCreatedDate,
          newFields: "",
          deleteFields: "",
          listVersion: "",
          async: false,
          completefunc: function (xData, Status){ 
              alert('Created Date is now available for modification'); 
          }
        });

Created field value can be updated using UpdateListItems operation:

var updatedDate = new Date('2018-01-01 6:00:00').toISOString();
$().SPServices({
    operation: "UpdateListItems",
    async: false,
    listName: "Events",
    ID: 1,
    valuepairs: [["Created", updatedDate]],
    completefunc: function (xData, Status) {
         alert('Created Date is successfully updated');
    }
});

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.