You are viewing limited content. For full access, please sign in.

Question

Question

Validate date in Quick Fields?

asked on October 23, 2017

Hello,

Is there a way to validate a date field in Quick Fields before assigning the value to a template field that will enforce the date type? I have an existing template that I cannot change; and need to validate a token value is a date before assigning it to metadata (otherwise it will get stuck in Quick Fields due to validation error).

 

Ideally the metadata field would not be enforcing this and I could handle in a workflow; but we have many other dependencies on this pre-existing template I inherited :-).

 

Thanks,

Julie

0 0

Answer

SELECTED ANSWER
replied on October 23, 2017 Show version history

A couple of questions:

  1. Is tkDate the source value or the Token you created?
  2. Are you obtaining the date through OCR?

 

What you would want is something like this:

  • Token - dateToken = EMPTY
  • OCR (if that is what you're using) - dateSource
  • Condition - if ALL of the following are TRUE
    • dateSource matches RegEx \d{1,2}/\d{1,2}/\d{4}
    • dateSource between START and END
      • dateToken = dateSource
  • Set Field Values
    • Date = dateToken

 

So, if the source date is 1/2/2017, 01/02/2017, etc., it will apply that to the Token, otherwise, it will leave it blank. Then, in either case the Token is assigned to the field: if it fits the requirements it will have the date, if not, it will be blank.

0 0

Replies

replied on October 23, 2017 Show version history

You could create a Token in Pre-Processing, then create a conditional as well. If the "date" meets the desired formatting, assign it to the Token, otherwise, leave the token blank. Then, assign the token value to the field instead of assigning the source value directly.

 

Other than that, the second easiest workaround would be to create an independent test field, store the value there instead in the Quick Fields session, then evaluate the value in Workflow.

When you set the field equal to nothing/empty with the workflow it will remove it, so you'll be able to validate outside of Quick Fields; no need to change the template, no change in what the user sees.

0 0
replied on October 23, 2017

Thanks Jason. Would you elaborate on your first suggestion (i.e., specifically what would be the test condition)? I am already using an interim token and there is already a general condition of "tkDate as Date is not between 1/1/2010 and 1/1/2050" but it obviously doesn't address the case of tkDate not being a valid date. Is there another condition I can add to check for a valid date?

0 0
replied on October 23, 2017

Perhaps my condition can be "if all of these conditions are false" and change the check to be "tkDate as Date is between 1/1/2010 and 1/1/2050". Then I could clear out the value. Just not sure if it might somehow error since I'm not checking for valid date first.

0 0
SELECTED ANSWER
replied on October 23, 2017 Show version history

A couple of questions:

  1. Is tkDate the source value or the Token you created?
  2. Are you obtaining the date through OCR?

 

What you would want is something like this:

  • Token - dateToken = EMPTY
  • OCR (if that is what you're using) - dateSource
  • Condition - if ALL of the following are TRUE
    • dateSource matches RegEx \d{1,2}/\d{1,2}/\d{4}
    • dateSource between START and END
      • dateToken = dateSource
  • Set Field Values
    • Date = dateToken

 

So, if the source date is 1/2/2017, 01/02/2017, etc., it will apply that to the Token, otherwise, it will leave it blank. Then, in either case the Token is assigned to the field: if it fits the requirements it will have the date, if not, it will be blank.

0 0
replied on October 23, 2017

Thanks Jason! Will give that a try.

0 0
You are not allowed to follow up in this post.

Sign in to reply to this post.