Prevent SaveAndPublishWithStatus from changing last edited date
Hi,
I am using the ContentService.Publishing event to update some fields in the parent node when the child node is published. This is working though I am finding that the Last Edited date on the parent is being updated automatically. Is there anyway I can avoid this happening? Snippet below:
private void ContentServicePublished(IPublishingStrategy sender, PublishEventArgs<IContent> e)
{
foreach (var node in e.PublishedEntities)
{
if (node.ContentType.Alias == "DiscussionReply")
{
var contentService = new Umbraco.Core.Services.ContentService();
var parentNode = contentService.GetById(node.ParentId);
int intSiblings = parentNode.Children().Count() + 1;
string strTitle = parentNode.Name;
if(parentNode.HasProperty("siblings"))
{
parentNode.SetValue("siblings", intSiblings);
contentService.SaveAndPublishWithStatus(parentNode);
}
}
}
}
I had the same issue and I didn't find a way to prevent updateting the updateDate field of the parent node. From my previous research I understand that this system field is not supposed to be used for business logic. When you publish item via contentService.SaveAndPublishWithStatus(parentNode); a lot of thing happens behind - a new version of the node is created (see your versions) and a record is created in the Authid trail.
In my case I change my business logic to not work with this date. If you have an option just create new custom field - myLastUpdateDate and work with this field instead of updateDate.
Prevent SaveAndPublishWithStatus from changing last edited date
Hi,
I am using the ContentService.Publishing event to update some fields in the parent node when the child node is published. This is working though I am finding that the Last Edited date on the parent is being updated automatically. Is there anyway I can avoid this happening? Snippet below:
Bump. I'm trying to work this out too.
Hi Ross,
I had the same issue and I didn't find a way to prevent updateting the updateDate field of the parent node. From my previous research I understand that this system field is not supposed to be used for business logic. When you publish item via
contentService.SaveAndPublishWithStatus(parentNode);
a lot of thing happens behind - a new version of the node is created (see your versions) and a record is created in the Authid trail.In my case I change my business logic to not work with this date. If you have an option just create new custom field - myLastUpdateDate and work with this field instead of updateDate.
Mila
is working on a reply...