Crow Canyon Software Forum

Forum Navigation
Please or Register to create posts and topics.

Replacing unwanted characters using the $regexreplace() function

I have a Custom Action that generates a document and uses the [Title] column as the filename. It gives an error if there is a character in the Title that is not valid in a file name, e.g. * / \, etc. I've been trying to use $regexreplace() function following the syntax at https://www.crowcanyon.help/article/comprehensive-list-of-functions-in-nitro-studio/ but cannot get it to work and if I try the example to simply remove spaces from the Title—$regexreplace([Title|Title],@\s,,,1)—it returns nothing.

How can I remove certain characters from a string, or replace them with spaces?

 

Hi,

Currently, "$regexreplace" function is available only in NITRO Workflows and not in Custom Actions.

We have below options for your requirement:

1. Configure validation on Title column to not enter special characters in it.

To configure validation, please go to the list -> List Settings -> Crow Canyon NITRO Forms -> Select Title column and configure the validation (see screenshot 1)

Validation Pattern: ^[\w\-. ]+$

2. Create a text column and hide this column on the form. Using custom script replace special characters from Title column and put the result in newly created text column. You can use this text column as file name in the custom actions.

Instructions:
1. Add text column on to the form and configure hide permissions
2. Configure form event actions when "Title" column value is modified (see screenshots below).

Script:
var Title = _ccs_FormUI.fetchColumnValueUI("Title");
Title = Title.replace(/[^a-zA-Z0-9]/g, ' ');
return Title;

Note: we will make below updates in near future:
- custom action code will remove special chars from file name automatically
- we will add regexreplace function in custom actions.

Uploaded files:
  • Title-column-validation.jpg
  • FAE1.jpg
  • FAE2.jpg

Thank you for the example, it worked in our form. I switched it around a bit and am BLOCKING invalid characters rather than ALLOWING only alphanumeric. The validation RegEx I ended up using is: ^[^\/\\:*\?<>\|]+$