Copied to clipboard

Flag this post as spam?

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


  • keilo 568 posts 1023 karma points
    Aug 30, 2015 @ 14:22
    keilo
    0

    How to implement interface for CustomData in SubscriptionProvider?

    In the version 2.1 how do we integrate the customData function into the CustomSubscriptionProvider?

    Say, if we are fetching the subscription list from external source and wish to collect the customData with it (like salutation, TelNo etc.).

    Can you share an example function how this can be done within customsubscriptionprovider?

    What I see for the baseprovider are following methods (in 2.1);

     public abstract class SubscriptionProviderBase
    {
        protected SubscriptionProviderBase();
    
        public abstract bool CanEditSubsciber { get; }
        public abstract string DisplayName { get; }
        public abstract string UniqueName { get; }
    
        public abstract string GetEditUrl(string subscriptionId, string email);
        public abstract IEnumerable<Model.ListItem> GetListItems();
        public abstract List<Receiver> GetSubscribersForSendOut(string listItemValue, SendOutParams parameters);
        public abstract bool Unsubscribe(string email);
        public abstract bool Unsubscribe(string email, string listItemId);
    }
    
  • Markus Johansson 1918 posts 5785 karma points MVP c-trib
    Aug 31, 2015 @ 08:38
    Markus Johansson
    1

    Hi!

    It's just to add the data to the Data-collection on the Receiver-object in your provider.

    This is a snippet from the new provider for the new Umbraco Members API looks:

    public override List<Receiver> GetSubscribersForSendOut(string listItemValue, SendOutParams parameters)
        {
     ......
    var receiver = new Receiver()
              {
                            Fullname = member.Name,
                            Email = member.Email,
                            DataProviderKey = member.Id.ToString(),
              };
    
              if(useCustomData)
              { 
                            var data = new Dictionary<string, object>();
                            data.Add("email", member.Email);
                            data.Add("username", member.Username);
                            data.Add("loginname", member.Username); // was called login name in older versions
                            data.Add("login", member.Username); // UI calles it login
                            data.Add("name", member.Name); // UI calles it login
    
                            foreach (var property in member.PropertyTypes)
                            {
                                data.Add(property.Alias, member.GetValue(property.Alias));
                            }
    
                            receiver.Data = data;
                        }
    

    }

  • keilo 568 posts 1023 karma points
    Sep 01, 2015 @ 17:18
    keilo
    0

    Thanks for the pointers.

    For instance the default return for GetSubscribersForSendOut () is something like;

    return (from item in listAll select new Receiver() { DataProviderKey = item.DataProviderKey, Email = item.Email, Fullname = item.Fullname }).ToList();
    

    In this case how do you pass 'custom data' in the return value from GetSubscribersForSendOut?

  • Markus Johansson 1918 posts 5785 karma points MVP c-trib
    Sep 01, 2015 @ 20:13
    Markus Johansson
    0

    Hi!

    Just rewrite your code and add a collection with custom data to the Data-property of your Receiver-object like in the example that I posted.

    Cheers!

    //m

  • keilo 568 posts 1023 karma points
    Sep 01, 2015 @ 20:22
    keilo
    0

    I have actually tried something like this;

    public override List

    And when i compile, send test blast to the list, I dont see the customData captured in EmailTrackingItems table CustomData column.

    Is there something else to it?

    cheers!

  • keilo 568 posts 1023 karma points
    Sep 03, 2015 @ 12:18
    keilo
    0

    In the above example, the custom data is added by

    receiver.Data = data;

    what should be the return call, as this doesnt seem to work:

    return (from item in listAll select new Receiver() { DataProviderKey = item.DataProviderKey, Email = item.Email, Fullname = item.Fullname }).ToList();
    

    how do we return the .data in that return call?

  • Markus Johansson 1918 posts 5785 karma points MVP c-trib
    Sep 03, 2015 @ 14:18
    Markus Johansson
    1

    In this line

    return (from item in listAll select new Receiver() { DataProviderKey = item.DataProviderKey, Email = item.Email, Fullname = item.Fullname }).ToList();
    

    You are creating a new collection of Receiver-objects without adding the datacollection to it. Should be:

    return (from item in listAll select new Receiver() { DataProviderKey = item.DataProviderKey, Email = item.Email, Fullname = item.Fullname, Data = item.Data }).ToList();
    
  • keilo 568 posts 1023 karma points
    Sep 03, 2015 @ 15:23
    keilo
    0

    Yes that works. Thanks Markus!

    I can see the data like Salutation in the customData column.

    When we use the placeholder in the email body like

    Dear [Salutation]

    it doesnt replace it automatically, does this mean one needs to write a rendertask for these? Not sure if I'm getting it right.

    Thank you!

  • Markus Johansson 1918 posts 5785 karma points MVP c-trib
    Sep 03, 2015 @ 16:13
    Markus Johansson
    0

    Hi!

    This feature is a little "undocumented" at the moment.

    1. Make sure that you're last render task in /config/newsletterStudio.config is:

      <task name="InsertCustomDataRenderTask" type="NewsletterStudio.Services.RenderTasks.Tasks.InsertCustomDataRenderTask, NewsletterStudio" />

    2. Make sure that you use the merge fields like this [#nameOfListItem]

  • keilo 568 posts 1023 karma points
    Sep 03, 2015 @ 16:34
    keilo
    0

    I checked the newsletterconfig and the last task is indeed set to that, InsertCustomDataRenderTask, re-checked for spelling too.

    Now if i go back and add like [#Salutation] in the email body and blast it, it doesnt seem to replace anything.

    When i check the column in the ns table it looks like this;

    {"Salutation":"Mr","ID":"0123456","Firstname":"Test","LastName":"Tester"}

    what is missing in this case?

  • Markus Johansson 1918 posts 5785 karma points MVP c-trib
    Sep 03, 2015 @ 16:48
    Markus Johansson
    100

    Hi!

    Sorry, forgot one thing. You need to activate the feature to use custom data as if you don't need it it will fill up the database with database with unnecessary data.

    So go to "General settings" and check the "Activate custom data collection", save and try again

    =D

    enter image description here

  • keilo 568 posts 1023 karma points
    Sep 03, 2015 @ 17:03
    keilo
    0

    That was it! It works after enabling the new setting attribute.

    Thank you

  • Markus Johansson 1918 posts 5785 karma points MVP c-trib
    Sep 06, 2015 @ 17:27
    Markus Johansson
    0

    Great news!

    Thank you!

Please Sign in or register to post replies

Write your reply to:

Draft