How to get the current date into a field value?

Question

How to get the current date into a field value?

 

Answer

  1. Create a field of a Date type in the Document Definition: mceclip1.png
  2. Switch to the Rules tab and add a new script rule.
  3. In the rule settings add the newly created field and make sure the Read Only option is disabled for the field.
  4. Use the following sample script as a reference:
    using System;
    using System.Globalization;

    DateTime currentDate = DateTime.Now;
    Context.Field("Field").Value = currentDate.ToString();

    mceclip2.png
  5. Save and publish the Document Definition.

Have more questions? Submit a request

Comments

0 comments

Please sign in to leave a comment.

Recently viewed