Posts

Showing posts from February, 2018

Sitecore Content authorable error messages for form validation in MVC

Image
I have created a form to get user input in Sitecore MVC application, it has different validation assigned like Required Field Validation  Regex validation  I have created a model for this Form objects and assigned the Out of the box.Net DataAnnotations Attributes along with the error message, but my business requested that these error messages need to be content authorable, but with this.Net out of the box we can’t achieve it, So I have created custom Attribute to manage these error messages from Sitecore. Before we dive in to create the custom attribute, it is necessary to have an item in Sitecore with all error messages for the fields that we going to use in the form, I have created an item with all necessary fields, but we can also go with Sitecore dictionary etc. Sitecore Item for error messages: So, let’s start creating the custom attributes to display content authorable error messages. ·          I’m going to create two Attributes one for Required

Sitecore EXM Programmatically sending email along with adding contact to list

Image
This post will get the user details from the Form and add these user details as a Contact to XDB, and it will trigger the EXM automated email that I have created in Sitecore after this contact was added to the ListManger. Steps to be done before getting hands dirty. Create an empty contact list using ListManager Create an Automated Email Campaign message in EXM(Choose this to send an email campaign, for example, when a visitor triggers a goal or event on your website.  Rule triggers Email Message on event ) Create Custom Facet that will hold all the user details received through the Form.Refer my post for  Custom contact Facet Let's start adding contacts to the List and send an Email.          public void AddContactToListAndSendEmail()         {             string emailAddress = "nels_jnjr4@yahoo.com" ;             ContactRepository contactRepository = Sitecore.Configuration. Factory .CreateObject( "tracking/contactRepository" , true )