1

I want to send only updated fields for Translation.

How can I know which fields have been updated on an item?

2 Answers 2

2

Assuming that there is new version created when items are being edited, you can take the latest version and previous version and compare each field.

Item originalItem = newItem.Database.GetItem(newItem.ID, newItem.Language, newItem.Version - 1);

newItem.Fields.ReadAll();

IEnumerable<string> fieldNames = newItem.Fields.Select(f => f.Name);

IEnumerable<string> differences = fieldNames.Where(fieldName => newItem[fieldName] != originalItem[fieldName]).ToList();

Of course, you should check if there is even older version of that item.

2
  • Will this get changes to shared/unversioned fields? I think not, but not sure.. (and I don't have a fix for that either)
    – Gatogordo
    Mar 31, 2022 at 13:28
  • That's true, it won't work with unversioned fields
    – Marek Musielak
    Apr 1, 2022 at 6:11
2

Sitecore doesn't give any option OOTB on field level. Sitecore manages the Revision field for each item that has any update, Sitecore's smart publish is based on this field. You need to compare this field of the item from the master database with the field of the same item in the web database to make sure the item has any updates or not. Once it will be clear that the item has updates, we can compare it with all the fields of the web database item to get the list of updated fields.

enter image description here

You can use a workflow stage for the above approach.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.