I have a requirement to limit the number of characters entered into a WYSIWYG field. I set up a validation rule to check if the asLength property of the field is > the number of characters, but it fires when far fewer characters than specified is entered.
If I change the field type from WYSIWYG to plain text, the validation rule works as expected, firing when the specified number of characters is exceeded.
I suspect it's because extra "stuff" is added to the WYSIWYG data, such as bold or italic or whatever, so asLength is counting all that as well.
Am I doing something wrong? Is there a way to get this working? Is there something besides the asLength property that can be used?
I put together a quick test form that does not behave as expected, shown here:
<ac:structured-macro ac:macro-id="1cffb15f-6562-4909-bb37-c1d5f2dbaedf" ac:name="confiform-card" ac:schema-version="1">
<ac:parameter ac:name="formName">TestForm</ac:parameter>
<ac:parameter ac:name="enableInlineAdd">true</ac:parameter>
<ac:rich-text-body>
<p>
<ac:structured-macro ac:macro-id="cc81ed3e-5bf3-44ed-ac87-61d1635f9907" ac:name="confiform-field" ac:schema-version="1">
<ac:parameter ac:name="fieldName">Description</ac:parameter>
<ac:parameter ac:name="withLabel">true</ac:parameter>
</ac:structured-macro>
</p>
<ac:structured-macro ac:macro-id="81b2a2ce-821a-4bc5-8917-168d7b31c842" ac:name="confiform-entry-edit" ac:schema-version="1">
<ac:parameter ac:name="inline">true</ac:parameter>
<ac:rich-text-body>
<p>
<br/>
</p>
</ac:rich-text-body>
</ac:structured-macro>
</ac:rich-text-body>
</ac:structured-macro>
<p>
<br/>
</p>
<ac:structured-macro ac:macro-id="029b473b-4ea3-4558-b796-3123caef6b80" ac:name="confiform" ac:schema-version="1">
<ac:parameter ac:name="printEnabled">true</ac:parameter>
<ac:parameter ac:name="formName">TestForm</ac:parameter>
<ac:rich-text-body>
<p>
<ac:structured-macro ac:macro-id="098774fd-0593-4620-a892-4205e2fc2846" ac:name="confiform-field-definition" ac:schema-version="1">
<ac:parameter ac:name="fieldName">Description</ac:parameter>
<ac:parameter ac:name="fieldLabel">Description (max 10):</ac:parameter>
<ac:parameter ac:name="type">wysiwyg</ac:parameter>
</ac:structured-macro>
<ac:structured-macro ac:macro-id="b54e4456-4727-44fc-961d-b8141e1c7949" ac:name="confiform-field-definition-rules" ac:schema-version="1">
<ac:parameter ac:name="condition">Description.asLength:>10</ac:parameter>
<ac:parameter ac:name="fieldName">Maximum of 10 characters</ac:parameter>
<ac:parameter ac:name="action">Validation rule</ac:parameter>
<ac:parameter ac:name="actionFieldName">Description</ac:parameter>
</ac:structured-macro>
</p>
</ac:rich-text-body>
</ac:structured-macro>
<p>
<br/>
</p>
Entering 1234567890 into that form fails, and even entering 1234 fails. Entering 123 works.
Thank you.