3 Replies Latest reply on Jul 2, 2018 9:36 AM by Dan Askin

    Birthday Field With No Year

    Dan Askin

      Assume the answer -- at least one answer -- is to create two integer fields and add some instructive text/egs/code on the form to show/force how to correctly fill in the fields, but. Mailchimp, for example, has a birthday field type.

       

      Also, trying to wrap my head around how you'd automate a birthday message if you have two custom fields.

       

      Thanks,

       

      Dan

        • Re: Birthday Field With No Year
          Jay Jiang

          If ultimately you just want to email people on their birthday, you can try using advanced wait + date token + next anniversary. Have 2 campaigns requesting each other so it becomes perpetual (a campaign can't request itself). To start someone off on the emails you may use a Data value changes trigger and Date of Birth is not empty.

           

          • Re: Birthday Field With No Year
            Sanford Whiteman

            Jay outlines perfectly why the Date datatype has special power in Marketo that you wouldn't be able to replicate any other way.

             

            If what you're actually trying to do is offer somebody a friendly form (where they don't feel the intrusion of telling you their age ) you can do that by using 2 auxiliary fields on the form.

             

            Technically, as you know from past work, you don't even need to create those fields in Marketo, but for simplicity's sake let's assume you have the 2 custom Integer fields MonthofBirth and DayofBirth in Marketo and on the form (as dropdowns or text fields or whatever).

             

            Then in onSubmit, assemble the DateofBirth as a hidden field, with year 1000 as a placeholder:

             

            MktoForms2.whenReady(function(form){  
               form.onSubmit(function(form){
                  var currentValues = form.getValues();
                  
                  form.addHiddenFields({
                     DateofBirth : 
                        ["1000"]
                        .concat(
                           ["MonthofBirth","DayofBirth"]
                           .map(function leftPad(field){
                             return ("0" + currentValues[field]).slice(-2);
                          })
                        )
                       .join("-")
                  });
               });
            });
            

             

            This allows you to use the usual anniversary logic as the field is stored as a Date.

            1 of 1 people found this helpful