+1-888-365-2779
Try Now
More in this section

Forums / General Discussions / Adding custom fields subscribers

Adding custom fields subscribers

5 posts, 0 answered
  1. Craciunescu
    Craciunescu avatar
    1 posts
    Registered:
    18 Feb 2009
    02 May 2013
    Link to this post
    I tried adding custom field to a subscriber.
    I used this code:

    var metaMan = MetadataManager.GetManager();
    var dynType = metaMan.GetMetaType(typeof(Subscriber));
    if (dynType != null)
    {
              metaMan.Delete(dynType);
              metaMan.SaveChanges(true);
    }
    metaMan = MetadataManager.GetManager();
    dynType = metaMan.CreateMetaType(typeof(Subscriber));
    var metaField =  metaMan.CreateMetafield('Token');
    metaField.DBSqlType = "NVARCHAR(150)";
    metaField.DBType = "LONGVARCHAR";
    metaField.ClrType = "System.String";
    dynType.Fields.Add(metaField);
    metaMan.SaveChanges(true);



    I checked the database, and the field is there, i populated this field with data, but I can't retrieve values.
    I tried with {|Subscriber.Token|} in message template, but is empty every time.

    Thanks,
    Stefan
  2. Pavel Benov
    Pavel Benov avatar
    341 posts
    Registered:
    14 Mar 2016
    06 May 2013
    Link to this post
    Hello Stefan,

    After the Sitefinity 5.1 release in which we have introduced the Notifications service the whole way the fields are resolved has changed. We are using the so called SubscriberRequestProxy which handles all the built in fields and displays them properly on the message, but it does not have logic for the custom fields. 

    The reason for this is that Sitefinity was never designed to be able to display those custom fields, however prior to the 5.1 release the workaround from Boyan Barnev in this forum post was working because Sitefinity was using the standard SMTP way.

    We have a PITS feature request logged in the system for this functionality. You can follow its progress and vote to increase its popularity.

    Regards,
    Pavel Benov
    the Telerik team
    Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  3. Chaitanya
    Chaitanya avatar
    22 posts
    Registered:
    14 Oct 2013
    07 Mar in reply to Pavel Benov
    Link to this post

    Hi Pavel,

    So what's the work around for this in latest Sitefinity version. Also I can not find PITS, can you share the link to this issue.

    Regards,

    Chaitanya.

  4. Sabrie Nedzhip
    Sabrie Nedzhip avatar
    534 posts
    Registered:
    26 Sep 2016
    10 Mar
    Link to this post
    Hello Chaitanya,

    Here is the link to the feedback item my colleague Pavel refers to in his post: http://feedback.telerik.com/Project/153/Feedback/Details/99009-email-campaigns-send-messages-with-custom-subscriber-fields

    As for creating custom fields for subscribers, currently we do not have a built-in functionality to add custom fields for subscribers from the backend UI. We have logged it in our system as a feature request and hopefully will be able to implement it for our future releases. Here is a link to our feedback portal where you can track its progress and vote for it: http://feedback.telerik.com/Project/153/Feedback/Details/99590-add-option-to-add-additional-fields-in-email-campaigns-subscribers-form

    In order to add a custom filed for the subscribers you will need to do this through our API as described in our documentation: http://docs.sitefinity.com/for-developers-create-custom-fields-for-subscribers. Please note that you will not have access to these fields from the backend UI as it is noted in the article. But after you add the fields you will be able to access then as the other default fields in Sitefinity 6.1 and above.

    Regards,
    Sabrie Nedzhip
    Telerik
     
    Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Sitefinity CMS Ideas&Feedback Portal and vote to affect the priority of the items
     
  5. Brandon
    Brandon avatar
    0 posts
    Registered:
    28 Sep 2015
    29 Aug
    Link to this post

    I am running Sitefinity 7.0 and have found a problem, it may be related...


    If you add your custom field to Subscriber then send an email there is caching that occurs in the database.

    1. if you run this query


    select *
    from sf_subscriber

    You will see your custom field and its values. Note: the custom field doesn't appear to be actually created in the DB until a Subscriber is saved for the 1st time following the change.

    2. Next, if you run this query... you'll see that the subscriber info is also stored in another set of tables... AFTER the 1st time they are sent an email. The resolve key value should be the ID of the Subscriber from the 1st query.

    SELECT
    *
    FROM sf_notif_subscribers s
    JOIN sf_ntf_sbscrbrs_cstm_prperties p
    ON p.id = s.id
    WHERE s.resolve_key = ''

    3. Now if you update your custom field on the Subscriber (sf_subscriber) to any value... the sf_ntf_sbscrbrs_cstm_prperties val is not updated and this is what you see in the email.

    My guess in your case is that the sf_ntf_sbscrbrs_cstm_prperties.val is an empty string. Their code example doesn't show how to update this cached value. I'm trying to find a solution now. Simply calling SetValue for the custom field and saving does not appear to work.

    Code example I'm referring to: http://docs.sitefinity.com/72/for-developers-create-custom-fields-for-subscribers
5 posts, 0 answered