0

Sitecore Version - 9.3

I have created a custom submit action but it is not working. It is not even getting called when I hit with debugger.

Submit Action Code -

using Sitecore;
using Sitecore.Data;
using Sitecore.Diagnostics;
using Sitecore.ExperienceForms.Models;
using Sitecore.ExperienceForms.Processing;
using Sitecore.ExperienceForms.Processing.Actions;
using System;
using System.Linq;
using System.Web;
using System.Collections.Generic;
using Sitecore.Analytics;
//using Sitecore.XConnect.Client;
//using Sitecore.XConnect;
//using Sitecore.XConnect.Collection.Model;
using Sitecore.Data.Fields;
using Sitecore.Resources.Media;
using Sitecore.Links.UrlBuilders;
 
 
namespace ProjectName.SitecoreForms.Actions
{
    [CLSCompliant(false)]
    public class SendEmailToCsd : SubmitActionBase<SendEmailActionData>
    {
 
        private ISubmitActionHelper _submitActionHelper;
 
        private IVisitorTokensProvider VisitorTokensProvider { get; }
        private static Guid PortalId
           => Context.Database.GetItem(Context.Site.RootPath).ID.Guid;
 
        public SendEmailToCsd(ISubmitActionData submitActionData) : base(submitActionData)
        {
            VisitorTokensProvider = new VisitorTokensProvider();
        }
 
        public SendEmailToCsd(ISubmitActionData submitActionData,
                              ISubmitActionHelper submitActionHelper,
                              IVisitorTokensProvider visitorTokensProvider) : base(submitActionData)
        {
            _submitActionHelper = submitActionHelper;
            VisitorTokensProvider = visitorTokensProvider;
        }
 
        private ISubmitActionHelper SubmitActionHelper => _submitActionHelper ?? (_submitActionHelper = new SubmitActionHelper());
       /// <summary>
        /// Execute method for custom submit action
        /// </summary>
        /// <param name="data"></param>
        /// <param name="formSubmitContext"></param>
        /// <returns></returns>
        protected override bool Execute(SendEmailActionData data, FormSubmitContext formSubmitContext)
        {
 
            try
            {

 
                //logic goes here
            }
            catch (Exception ex)
            {
                Log.Error("Some error occurred while sending email to CSD ", ex, this);
                return false;
            }
 
        }
 
       
    }
}

Submit Action Item -

enter image description here

enter image description here

Can someone please suggest what I may have missed here?

10
  • Did you select this custom action on your submit button on the form? Nov 20 at 13:32
  • yes let me add a screenshot of that as well.
    – NewbieHere
    Nov 20 at 13:33
  • @SumitBhatia updated screenshot
    – NewbieHere
    Nov 20 at 13:36
  • are you getting any error in logs and on browser console? Also when you remove the save data and keep only the custom one. what happens? Nov 20 at 13:38
  • Have you published that submit action item?
    – Marek Musielak
    Nov 20 at 13:39

1 Answer 1

1

As per our discussion in chat, Here are the possible solutions to troubleshoot your issue.

  • You can check the assembly name in your Sitecore item

  • check if it was deployed to your solutions.

  • Check if the item is published.

  • Examine Sitecore logs for any error messages or exceptions related to your custom submit action. Ensure that the necessary logs are enabled in the Sitecore configuration.

  • Use the browser's developer tools to check for any JavaScript errors when submitting the form.

  • Inspect network requests to see if there are any issues with data being sent or received.

  • Double-check your Sitecore configuration files to ensure that the custom submit action is correctly registered.

  • Confirm that the form is configured to use the correct submit action.

  • Clear Sitecore and browser caches to ensure that you are not encountering caching-related problems

Hope this helps.

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