Sitecore – Posting Directly to CD Environment

Forms/View Rendering Posting Data directly into CD environment and preventing it from overridden by Publishing

There might be a scenario where we can not push content/data directly into the CA environment or ‘master’ db. It could be because any of the following reasons:

  • From CD or production environment, master db can’t be accessed.
  • A new table or database can not be introduced as current system can’t support additional resources.
  • End user wants to view the records submitted till that moment, but its an extranet user or don’t have access to Sitecore interface.



There is a requirement where users category as Employee are supposed to fill a profile form and enter all information related to them like Personal, Education, Professional, Compensation, Travel and Relocation Preferences, Technical skills. Further to this, an HR personnel will login to the same system and view the records of all the employee’s. Look’s straightforward, isn’t it? But the fun part is that none of these users have access to sitecore.


Technology & Tools Used:

Sitecore 8.1, Glass Mapper, MVC 5, TDS


Design approach:

Once the user clicks on ‘submit’ and after performing all the necessary client side and server side validations and code execution, data items (which is a particular employee record in our case) will be created and saved in the Sitecore content tree node for e.g. /sitecore/content/home/EmployeeRecords/

Once content items are created, prerequisites to which are the creation of necessary

  • Employee Item’s template creation.
  • EmployeeRecords Parent node

Items can be made bucketable, if it suits your requirement.



Once items start getting created under that node, please notice that all this is happening in the Web/prod database. All will be lost if editors do a bulk publish or publish that */EmployeeRecords/ content node.



Prevent that particular node in the Sitecore content tree from being overridden, in case of a publishing by adding a pipeline as explained below.

Add this patch config file in your solution

<configuration xmlns:patch="">
            <event name="publish:itemProcessing" help="Receives an argument of type ItemProcessingEventArgs (namespace: Sitecore.Publishing.Pipelines.PublishItem)">
                <handler type="Company.Web.Utility.ItemProcessing, Company.Web" method="CheckIfEmployee" />


namespace Company.web.Utility
    public class ItemProcessing
        public void CheckIfEmployee(object sender, EventArgs args)
              var theArgs = args as ItemProcessingEventArgs;
              var item = theArgs.Context.PublishHelper.GetSourceItem(theArgs.Context.ItemId);
              //Employee_RECORDS_ROOT_ITEM_ID is the Item ID of the /sitecore/content/home/EmployeeRecords/
              if (item.ParentID.ToString() == Constants.Employee_RECORDS_ROOT_ITEM_ID||
              item.ID.ToString() == Constants.Employee_RECORDS_ROOT_ITEM_ID)
                theArgs.Cancel = true;
            catch (Exception ex)
              Sitecore.Diagnostics.Log.Error("Error in method CheckIfEmployee", ex, this);



This feature can be extended to prevent publishing based on some template, path or any particular case. Even if children’s or sub-children’s are created under the /EmployeeRecords/ node in master db and published. This will neither override the web db nor it will publish these changes.


Do let me know, if you have any feedback onto this.


About The Author

Leave a Reply