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

Question

Question

Help with regular expression (admin console metadata field constraint)

asked on April 11, 2016

Hello,

I am trying to add a regular expression to one of our number metadata fields (using the constraint box within the admin console) and continue to get the error "The field constraint has a syntax error or is invalid". I have used the expression within workflow, quickfields, etc... and validated so not sure what is wrong besides constraints within the admin console are different from other areas of laserfiche. Below is the expression I am trying to use (validating numbers to have at least one decimal and correct comma separation if used). I have tried removing the starting/stopping elements and also adding forward slashes just to try to eliminate possible issues.

 

^(0|[1-9][0-9]{0,2}(?:(,[0-9]{3})*|[0-9]*))(\.[0-9]{2})$

 

Thanks for any help!

Kipp

0 0

Replies

replied on April 11, 2016

Hey Kip,

 

I see what you're doing and the issue is with the pipe for the OR statement. Looking to see if the Template Field Constraints offers another way to achieve this.

 

-Carl

replied on April 11, 2016

Hi Kipp,

 

To do this, I believe you need to set the Field Type to Text.

 

The number fields use a different syntax for regular expressions and does not includes comma support.

 

Cheers,

Carl

0 0
replied on April 11, 2016

Hi Kipp,

You can use the number field and have LF apply the commas automatically with a custom field type,  something like Custom [#,###,##0.0#].     User enter the number field without commas.   Then your RE becomes a simple check a checking for one decimal.
More details on custom number fields:

https://www.laserfiche.com/support/webhelp/Laserfiche/10/en-US/administration/#../Subsystems/LfAdmin/Content/Custom_Number_Field_Display.htm

Andrew

0 0
replied on April 11, 2016

Thanks Carl/Andrew!

 

I was afraid the OR might be the problem, but wasn't sure. I might continue down this road but also might try the masking type solution Andrew mentioned. Need to talk with the users about a few of their requirements.

 

Thanks again!

 

Kipp

0 0
replied on April 11, 2016

Well the custom format won't work because it helps the user but doesn't validate to make sure decimal points are present. I tried "text" but that didn't work either. My last try I dumbed down the expression to basically allow all number before a decimal and then 2 after and still no luck -- ^(\d{1,}\.\d{1,2})$

 

In the end I just need to make sure the field has one decimal point. I believe at this point I will put the validation within quick fields and workflow and solve in this manner.

 

Thanks again for the help

Kipp

0 0
replied on April 11, 2016

Ah.

 

FYI Miruna's answer over here sort of walks around this OR issue and denotes the ()'s are only allowable in grouping constructs.

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

Sign in to reply to this post.