The batch name is not changed with the script stage

Symptoms

There is a script stage created to modify the batch name, but the batch name is not changed.

When navigating to Administration and Monitoring Console > Processing Monitor > Event log there are the following errors.

mceclip0.png

mceclip1.png

Error: A name cannot contain character 'x' at
Error: The name is too long. Maximum length is 90.

Cause

  • The modified batch name contains forbidden characters (e.g. the ones used in Windows paths). 
  • The modified batch name exceeds the limit of 90 characters.

Resolution

If the error is caused by the forbidden characters (e.g. slashes, colons, etc.), the name can be edited to replace these characters with an empty character or a replacement character.

//C# eaxmple
var name = Batch.Documents[0].Field("Invoice Layout\\Name").Text;
var name_edited = name.Replace(":", "+");

Batch.Name += "_"+ name_edited;

If the error is caused by the exceeded 90-character limit, the string can be trimmed before assigning it to the batch name.

//C# eaxmple
Batch.Name = batch_name.Substring(0, 90);

Additional information

String.Replace Method (docs.microsoft.com)

String.Substring Method (docs.microsoft.com)

Have more questions? Submit a request

Comments

2 comments

  • Avatar

    Permanently deleted user

    Is there a list of all forbidden characters?

    0
  • Avatar

    Blake Smith

    What is the proper way to replace multiple invalid characters?

    0

Please sign in to leave a comment.