How to remove specific characters from the end of the field value?

Question

How to remove specific characters from the end of the field value?

Answer

  1. Navigate the document definition and open the properties of the field that should be corrected.
  2.  Navigate to the Data tab and click Edit in the AutoCorrect section.
  3. Put a checkmark in the Use Script field to enable the autocorrection script and click Edit:mceclip0.png
  4. Paste the following C# code into the Script Editor:
if (Value.Text.Contains("ABC"))
{
Value.Text = Value.Text.Remove(Value.Text.Length - 3);
}

mceclip2.png

The script above will remove "ABC" from the end of the field value.

To adjust it to ones needs, the "ABC" string in the if condition should be replaced with the one that is expected to be removed from the end of the field value, and number 3 should be replaced with the number of characters that need to be removed.

Additional information

Autocorrection script

Have more questions? Submit a request

Comments

0 comments

Please sign in to leave a comment.