Community

field length

Hello everyone

I have a field with a maximum length of 20 characters, if you pass 20 characters, I would like to receive a warning message that has more than 20 characters, but if there are less than 20 characters, how can I get a message telling me that the 20 characters are missing, this field by obligation will always always have 20 characters

Was this article helpful?

0 out of 0 found this helpful

Comments

1 comment

  • Avatar
    Vladimir Dimitrijević

    Hi,

    You will have to create 2 rules: one warning and one error. Double click on field in document definition, in tab Rules add new rules. Click on Edit script and add C# code so your rule error will look something like this:

    string field = Context.Field("Your field name").Text;
    if(field.Length < 20) {
        Context.ErrorMessage = "Field has less than 20 characters";
        Context.CheckSucceeded = false;
    }

    For warning,  you need it just as information that there are more than 20 characters, or you want to throw rule error and prevent document been processed?

    Best regards,
    Vladimir

    0

Please sign in to leave a comment.