Sarthak Gupta
Sarthak Gupta

Reputation: 205

Edit a field of sitecore item programmatically without updating it's "Updated" field

I need to update a sitecore item field programmatically but do not want to update it's field "Updated"

I know how to edit a sitecore item's field programmatically but at the same time i do not want to update it's "Updated" field as i am retrieving sub items from one folder so based on their updated date i need to fetch first 5 sub items.

CurrentItem.Editing.BeginEdit();
CurrentItem["MyField"] = "Hello!";
CurrentItem.Editing.EndEdit();

Now i need to run a job to update all these subitems programmatically but do not want to update it's "Updated" field

Upvotes: 0

Views: 2103

Answers (1)

user6931768
user6931768

Reputation:

We can instruct Item EditContext not to update Sitecore statistics. Sample code below:

bool silent = true;
bool updateStatistics = false;

using (SecurityDisabler disabler = new SecurityDisabler())
{
    using (new EditContext(item, updateStatistics, silent))
    {
        item["ShortHeadline"] = item["Title"];    
    }
}

Upvotes: 1

Related Questions