V15.1 manipulate content during publishing event
# help-with-umbraco
b
We have a scenario where we need to manipulate content when a user presses "Save and Publish." Specifically, we want to convert links to a short format, but only during publishing. When "Save and Publish" is triggered, a publishing notification is also triggered. Within this notification, we use the ContentService to locate the page and update its content. However, once we update the content, we need to perform another "Save and Publish" to save the changes. This, in turn, triggers a new publishing event, creating an infinite loop. Is it possible to use the ContentService to perform a "Save and Publish" operation without triggering a notification? Alternatively, should we handle this scenario in a different way?
l
Why does it explicitly have to be only on publishing? In Umbraco 13 (not sure about 15), during the saving event, you can change data and you don't need to explicitly save again, because all changes are saved implicitly later. In the saved event, you cannot actually call another save, because it will actively block that to prevent the loop you just described.
b
I've recently done something similar and can +1 what Luuk says. But if for some reason that is not an option, you can create a scope using the IScopeProvider and use scope.DisableNotifications() to prevent a new event being triggered. Option 1 is way better though imo
b
We wanted only to modify the data when the user decided to da a publish. However We changed the flow to do the data manipulation during saving. The other approach ended up being a bit hackish 😛
4 Views