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 16 posts 178 karma points notactivated
    20 days ago
    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 5 posts 76 karma points
    19 days ago
    Robert Sikkens
    0

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

  • Alex Skennerton 16 posts 178 karma points notactivated
    19 days ago
    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.

Please Sign in or register to post replies

Write your reply to:

Draft