Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Alex Skennerton 17 posts 179 karma points notactivated
    Apr 11, 2024 @ 20:30
    Alex Skennerton
    0

    Linking Umbraco Forms with Newsletter Studio

    I am trying to create a custom workflow within Umbraco forms to allow users to sign up for a mailing list in Newsletter Studio.

    The form works and the workflow runs but no information is copied into the mailing list, what am I missing?

    using Umbraco.Forms.Core;
    using Umbraco.Forms.Core.Enums;
    using Umbraco.Forms.Core.Persistence.Dtos;
    using NewsletterStudio.Core.Public.Models;
    
    namespace MyFormsExtensions
    {
    
        public class Subscribe : WorkflowType
        {
        public Subscribe()
        {
            Name = "Newsletter Sign-up";
            Id = new Guid("7793f98d-266f-4905-b2f2-9d27438da763");
            Description = "Add sign-ups to the mailing list";
            Icon = "icon-inbox";
        }
    
        public override WorkflowExecutionStatus Execute(WorkflowExecutionContext context)
        {
    
                RecordField? recordNewsletteremail = context.Record.GetRecordFieldByAlias("email");
                RecordField? recordName = context.Record.GetRecordFieldByAlias("name");
                RecordField? recordDistrict = context.Record.GetRecordFieldByAlias("district");
                var newsletteremail = recordNewsletteremail.ValuesAsString();
                var name = recordName.ValuesAsString();
                var district = recordDistrict.ValuesAsString();
    
            var request = AddRecipientRequest.Create(newsletteremail)
                .WithSource("Footer")
                .WithName(name)
               .WithCustomField("District", district)
               .SubscribeTo(Guid.Parse("15C21B14-2673-40E1-9730-ED04B4161DE4"))
                .Build();
    
            return WorkflowExecutionStatus.Completed;
        }
    
        public override List<Exception> ValidateSettings()
        {
            return new List<Exception>();
    
    
        }
        }
    }
    
  • Robert Sikkens 7 posts 78 karma points
    Apr 12, 2024 @ 12:02
    Robert Sikkens
    0

    I'm taking a guess, I have a workspaceKey in my code. Add to request something like .ForWorkspace(yourKey)

  • Alex Skennerton 17 posts 179 karma points notactivated
    Apr 12, 2024 @ 13:03
    Alex Skennerton
    0

    thanks, I've tried it both with and without the workspace key, in the documentation it says if you don't include one it will use the default workspace which is the only one I have.

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies