Skip to content

Commit

Permalink
Content Item published before Custom Form submit event triggers (#8795)
Browse files Browse the repository at this point in the history
* Moved content item publish before triggering form submit events.
Refreshed the content item passed in the context of rules manager and workflow manager.

* Added version to content manager get call after conditionally publishing the content item.
  • Loading branch information
AndreaPiovanelli authored May 17, 2024
1 parent fc8b681 commit 6e4fefd
Showing 1 changed file with 7 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,13 @@ private ActionResult CreatePOST(int id, int contentId, string returnUrl, Action<

contentItem.As<ICommonPart>().Container = customForm.ContentItem;

// save the submitted form
if (customForm.SaveContentItem) {
conditionallyPublish(contentItem);
// Refresh content item
contentItem = _contentManager.Get(contentItem.Id, VersionOptions.Latest);
}

// triggers any event
_rulesManager.TriggerEvent("CustomForm", "Submitted",
() => new Dictionary<string, object> { { "Content", contentItem } });
Expand All @@ -210,11 +217,6 @@ private ActionResult CreatePOST(int id, int contentId, string returnUrl, Action<
returnUrl = _tokenizer.Replace(customForm.RedirectUrl, new Dictionary<string, object> { { "Content", contentItem } });
}

// save the submitted form
if (customForm.SaveContentItem) {
conditionallyPublish(contentItem);
}

// writes a confirmation message
if (customForm.CustomMessage) {
if (!String.IsNullOrWhiteSpace(customForm.Message)) {
Expand Down

0 comments on commit 6e4fefd

Please sign in to comment.