CSOM SharePoint Update Created Field of InfoPath file in Document Library

While doing a bulk import of InfoPath documents into document library using a CSV file  the “Created” list out of the box date field is set to today’s date and time.

The “Created” date needed to be set to another date property “Date Raised”.

The InfoPath form can be uploaded following the steps described in the post


The InfoPath item can be retrieved specifying the URL of the file and field “Created” set to another date.

Microsoft.SharePoint.Client.File newFile = clientContext.Web.GetFileByServerRelativeUrl(fileUrl);
ListItem item = newFile.ListItemAllFields;
newFile .CheckOut();
DateTime dateRaised;
DateTime.TryParseExact ("24/04/1998", "d/M/yyyy",        CultureInfo.InvariantCulture, DateTimeStyles.None,
out dateRaised);
item["Created"] = dateRaised.ToString("yyyy-MM-dd");
newFile.CheckIn("Date Created Updated",CheckinType.MajorCheckIn);


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s