SharePoint Designer Workflow Date Strings

Recently I needed to create a custom column identifier using the ID field.  I would normally use a calculated field to do this, but calculated fields do not work with the ID field, because the ID field is not updated until after the item is created, so there is a timing issue.  If we use a Designer workflow to fire when a new item is created, we can use the ID field because the workflow runs after the item created event.

Calculated Field

The calculated filed can easily pull the year our of the Created date/time.

But if we include the ID column, the ID portion will remain blank or at least not consistently work correctly.

Designer Workflow

  1. Create a Local Variable
    1. Name: ISODate
    2. Type: String
  2. Create a local Variable
    1. Name: DateYear
    2. Type: String
  3. Create a step
    1. Title: Get Year
  4. Add Action
    1. Set Workflow Variable
    2. Set: Variable: ISODate to Current Item:Created (Make sure Return Field as: ISO Formatted)
  5. Create another step
    1. Title: Set Risk ID
  6. Add Action
    1. Under Section Utility Actions at the bottom, select Extract Substring from Start of String
    2. Copy 4 characters from start of Variable: ISODate (Output to Variable: DateYear)
  7. Add Action:
    1. Set the workflow variable to a Single Line of Text field combined with the other columns necessary.
    2. then Set Risk ID to Risk-[%Variable: DateYear%]-[%Current Item: ID%]
This process can be used to grab the day or month as well, the Extract Substring command will change, for example:
To Grab Month:
  1. Create a different variable, type as String, name perhaps: DateMonth.
  2. Copy from Variable: ISODate, starting at 6 for 2 characters(Output to Variable: DateMonth)

To Grab Day:
  1. Create a different variable, type as String, name perhaps: DateDay.
  2. Copy from Variable: ISODate, starting at 9 for 2 characters(Output to Variable: DateDay)


  1. Thanks for this post, I’ve been using this now for a while and has been working great


Post a Comment

Popular posts from this blog

SharePoint Designer 2013 Approval Workflow with Comments

Change SharePoint server hostname and Web Application Names

SharePoint Search - Content Processing Pipeline Failed to Process the Item