I'm trying to implement custom submit action in Sitecore 9 Forms according to the guide, but found the problem with Tracker.Current
which is null
while accessing from SubmitActionBase
.
Tracker
is fine in other areas (e.g. while accessing from view controller). If I call Tracker.StartTracking();
inside the action then Tracker.Current
is ok as well.
Additional conditions:
- form is ajax enabled
- save action is called on "Next" navigation step, not on "Submit"
Is this expected behaviour in Forms submit action?
Here's part of the code:
public class UpdateContact : SubmitActionBase<UpdateContactData>
{
public UpdateContact(ISubmitActionData submitActionData) : base(submitActionData)
{
}
protected override bool Execute(UpdateContactData data, FormSubmitContext formSubmitContext)
{
//Tracker.Enabled is true
//Sitecore.Context.Site.Tracking().EnableTracking is true
//Tracker.IsActive is false
var contact = Tracker.Current.Contact; //Tracker.Current is null
}
}