Sunday, May 19, 2024
 Popular · Latest · Hot · Upcoming
190
rated 0 times [  191] [ 1]  / answers: 1 / hits: 7838  / 9 Years ago, sat, september 19, 2015, 12:00:00

I manage a request list in SharePoint 2013, and I need to import some requests from another list. However, I want to keep the original request date rather than have SharePoint assign the current date/time that I upload the requests, so I want to change the default Created date field. I got this to work for a date column that I added:



var duedate = new Date(2015,01,11).toISOString();
$().SPServices({
operation: UpdateListItems,
async: false,
listName: Requests,
ID: 5,
valuepairs: [[DueDate, duedate]],
completefunc: function (xData, Status) {
}
});


It doesn't work for the Created field though - I think because it's read only. I need a way to make the Created field editable so I can change the date. I have a lot of code already written that references this column so I would rather not make a new column that defaults to Created unless changed.



Bonus: my next task will be to change the default Author field so hopefully the solution can also make that field editable.


More From » jquery

 Answers
1

The short answer: you cant. System fields such as Created, Modified, Created By, Modified By are not supported to be updated via SharePoint Web Services UpdateListItems operation.




Note: Created By (Author) and Modified By(Editor) fields can be
updated in this manner only for non-library SharePoint lists




But there is a workaround. Basically the reason why those field could not be updated is because they are declared as ReadOnly. So, after modifying list schema to make system fields available for modification (set ReadOnly attribute to false) as shown below for Created field:



var updateSystemFields = <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: Requests,
listProperties:,
updateFields: updateSystemFields,
newFields: ,
deleteFields: ,
listVersion: ,
async: false,
completefunc: function (xData, Status){
console.log('List schema has been modified');
}
});


list item Created field value could be updated using UpdateListItems operation:



var dueDateVal = new Date('2016-01-01 6:00:00').toISOString();
$().SPServices({
operation: UpdateListItems,
async: false,
listName: Requests,
ID: 1,
valuepairs: [[Created, dueDateVal]],
completefunc: function (xData, Status) {
console.log('List item has been updated');
}
});

[#34055] Friday, September 18, 2015, 9 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
masonm

Total Points: 167
Total Questions: 87
Total Answers: 103

Location: Rwanda
Member since Wed, Jun 8, 2022
2 Years ago
masonm questions
;