Programmatically updated a field in the backoffice
Hi,
I am capturing the save event using private void ContentService_Saving(IContentService sender, SaveEventArgs
Now, using e.SavedEntities, I can then update a given field in the page being saved, using its alias, as shown below. But how do you update other pages, not just the one being saved at that time?
You can fetch them with IContentService.GetByIds().
For instance
var otherId = Convert.ToInt32(item.Properties["relatedThing"].Value);
var otherItem = sender.GetByIds(otherId);
otherItem.Properties["someField"].Value = "Some value for the other thing";
sender.Save(otherItem, raiseEvents:false); // false to avoid recursive Saving event
Programmatically updated a field in the backoffice
Hi,
I am capturing the save event using private void ContentService_Saving(IContentService sender, SaveEventArgs
Now, using e.SavedEntities, I can then update a given field in the page being saved, using its alias, as shown below. But how do you update other pages, not just the one being saved at that time?
Thanks a lot!
foreach(var item in e.SavedEntities) { item.Properties["fieldName"].Value = "test 2"; }
You can fetch them with
IContentService.GetByIds()
.For instance
is working on a reply...