Special Characters in Process Automation
search cancel

Special Characters in Process Automation


Article ID: 28797


Updated On:


CA Process Automation Base


If CA PAM (Process Automation) is manipulating special characters, either in javascript operators, or in pre / post execution the character will be taken as code and will cause different problems, from the character being dropped, to code not executing correctly.

Process Automation is essentially a development tool.  As such one can have strings that need to be interpreted by Perl, Javascript, Windows Shell, Unix Shell, Web Service calls, Powershell, etc; you may want to pass special characters to any of these in order to perform language specific functions or you may want to pass static strings.

Just like other general purpose development tools Process Automation cannot predetermine the purpose of your string.  That is why all of these languages/APIs have functionality, not all of them the same, to indicate a string is a "static" string and a way to escape special characters.




Process Automation 4.3


The need to encode the string or not needs to be explicitly defined and can only be determined with an full understanding of the activities being programmed into a PAM Process.  This is not PAM specific functionality, this is standardized technology which is being leveraged by Process Automation.

For example, using JavaScript, when you do something like Process.inpString.toUpper() you aren’t really telling “PAM” to convert the string to all uppercase.   You are calling a JS function that converts a string to uppercase. 

This is important because we simply can not document and convey all possible functionality of all possible function calls that can be leveraged from within PAM and expect a certain level of understanding of the code language(s) being used. 

As an example, you could specifically tell PAM to replace special characters explicitly:

Process.outputString = Process.inputString.replace(/&/g, "&");
Process.outputString = Process.inputString.replace(/</g, "&lt;");
Process.outputString = Process.inputString.replace (/>/g, "&gt;");
Process.outputString = Process.inputString.replace (/"/g, "&quot;");
Process.outputString = Process.inputString.replace (/&apos;/g, "&apos;");

Or in JavaScript the encoding can be done by using the .encodeURI() function versus the individual replace function listed above.

This can be used in place of the multiple .replace statements, where instead of telling PAM to encode each specific character, possibly requiring many lines of replace statements, you are telling PAM to encode the entire string with a single line.

Please see http://www.w3schools.com/jsref/jsref_encodeuri.asp for more information.

Both are legitimate ways to address issues with special character and it is likely both the .encodeURI and the .replace JavaScript functions have their place and usage depending on the requirements of a particular process design. 

Another potential workaround to try is the replacement of the apostrophe by a %, which would represent a wildcard in the query.


Additional Information

You should also be aware that if a text value is passed into a Run Script operator that contains carriage returns, those carriage returns can cause the script to fail or return incorrect results.