Copied to clipboard

Flag this post as spam?

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


  • Mark Chen 2 posts 82 karma points
    Mar 26, 2019 @ 00:18
    Mark Chen
    0

    How to prefill a document type name?

    How to prefill the document type name that I circled in the picture below?

    enter image description here

  • AddWeb Solution Pvt. Ltd 15 posts 146 karma points
    Mar 26, 2019 @ 07:00
    AddWeb Solution Pvt. Ltd
    100

    This can be easily done using Events, on Document.New

    Just create a new class (eg. UmbracoEvents.cs)

    using System;
    using umbraco.BusinessLogic;
    using umbraco.cms.businesslogic.web;
    using Examine;
    
    public class UmbracoEvents: ApplicationBase
    {
      /// <summary>Constructor</summary>
      public UmbracoEvents()
      {
        Document.New += new Document.NewEventHandler(Document_New);
      }
    
      private void Document_New(Document sender, umbraco.cms.businesslogic.NewEventArgs e)
      {
        if (sender.ContentType.Alias == "News")
        {
          sender.getProperty("date").Value = DateTime.Today; // Set the date for a new News item to today
        }
      }
    }
    

    For More Understanding please refer below link

    https://our.umbraco.com/Documentation/Getting-Started/Code/Subscribing-To-Events/

  • Mark Chen 2 posts 82 karma points
    Mar 26, 2019 @ 21:17
    Mark Chen
    0

    Document.New is deprecated! Please use ContentService.Created!

Please Sign in or register to post replies

Write your reply to:

Draft