IT Process Automation

 View Only

Function trim() Not Supported in PAM 4.x 

Jul 21, 2015 03:35 AM

The JS engine PAM 4.x uses does not support trim(). If you attempt to use it in a javascript code in a PAM Run Javascript Operator, it will result in an error similar to this:


--TypeError: Cannot find function trim. (#16).


The alternative is to use this instead:




For example:


var trimmedTitle = Process.theTitle.replace(/^\s+|\s+$/gm,'');

0 Favorited
0 Files

Tags and Keywords


Sep 08, 2015 08:08 PM



PAM uses the Rhino JS engine, which is on JS 1.7  (assuming they are current)-



trim wasn't introduced into mozilla's JS world until 1.8.1 -


Browsing around on that page should give you a decent idea as to what is or isn't contained in PAM's JS engine.


You could also try looking up the ECMA documentation from ECMA 3 -,%203rd%20edition,%20December%201999.pdf


But that's not necessarily === to what's in Rhino's JS engine.

Aug 19, 2015 11:29 PM

Hi Ian,


I can't see a list at this time but I am providing a CA Techdoc that may explains the situation better:



Document ID:  TEC1707193

Last Modified Date:  3/30/2015

Show Technical Document Details


If Pam 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. 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.


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 language being used.


You could specifically tell PAM to replace special characters explicitly:


  1. Process.outputString = Process.inputString.replace(/&/g, "&");
  2. Process.outputString = Process.inputString.replace(/</g, "&lt;");
  3. Process.outputString = Process.inputString.replace (/>/g, "&gt;");
  4. Process.outputString = Process.inputString.replace (/"/g, "&quot;");
  5. 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 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.





Aug 17, 2015 03:51 PM

Is there a list somewhere of the functions (especially string-related) that the JS Engine the PAM uses supports?


I bounce between programming in different languages, and I often find myself struggling to remember which JavaScript functions I can use in PAM and which ones I can't.

Related Entries and Links

No Related Resource entered.