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

Question

Question

Field Constraint on Template

asked on May 3, 2023 Show version history

So I have a constraint I'd like to implement on a field that seems to work in Pattern Matching but not with implemented on the field.

I have a agenda number which is the two digit date, two digit number, and the optionally a letter.  

The below works - two digits, a dash, two digits, and the zero or one word character.

 

Here is the field constraint

When I go to the field I can enter whatever I wish and there is no error message

 

If I remove the \w? it seems to work.  It puts in the dash and does not let me enter other items.  But I need the \w? to account for a possible letter.  Any reason why this would not work?

 

 

Thanks,

Chris

0 0

Answer

SELECTED ANSWER
replied on May 3, 2023

I've found the RegEx options that exist for field constrants are a little different than RegEx used elsewhere.

Looking at the help files for field contrants, I don't see \w listed.

It lists word characters as [[:word:]]

So maybe try (I haven't specifically tested this myself) the following:

\d\d-\d\d[[:word:]]?

0 0
replied on May 3, 2023

Thanks Matthew,

I guess I should have checked the file - just thought regex was the same throughout.

Ultimately it was the following.  They can enter a capital A through G and the initial space is for no letter.  That seems to do the trick.

\d\d-\d\d[ ABCDEFG]

1 0
replied on May 3, 2023

Fantastic!  I'm happy you were able to find something that worked for you.

0 0

Replies

replied on May 3, 2023

Template field constraints will only show the mask in the field for fixed length constraints. That's why you see the dash with \d\d-\d\d. Any other constraints will be enforced when the field loses focus or when the user attempts to save.

2 0
replied on May 3, 2023

To make a character optional use *, not ?

\d{2}-\d{2}\w*

I recommend you do all your RegEx testing on a third party site. It's easier. My preferred tool is regex101.com 

Laserfiche's programs don't conform 100% to standard regex, mostly only with line breaks, so this kind of thing can be tested there no problem. 

replied on May 3, 2023

I checked your regex on regex101.com (I find using a third party tool like this instead of testing in Laserfiche saves time and hair pulling) and it should work. 

I assume from the partial screen shots this is Quick Fields. I've often had to monkey around with session and/or document class tokens, or even have a workflow take over after a document is sent on from QF to the repository to fix things. 

It's not a great solution, I've seem some ugly messes of documents being bounced back and forth between WF and QF where even the original process creator doesn't know what it's doing, but sometimes it's the only way. 

replied on May 3, 2023

Personally, I would avoid using field constraints on metadata fields entirely. Instead add logic to the workflow (I assume you have a workflow for organizing and filing the documents) that triggers on create/change/schedule to look for bad values in that field, try to extract document text to fix, and divert to review folder for a human to fix if it can't solve by itself. 

Years of frustration with things getting hung up in IA/QF had me emphasise getting the documents in the repository with as little friction as possible, and doing fancy stuff with workflows once the documents are there. 

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

Sign in to reply to this post.