Hi,
Thank you for your enquiry.
If the user cancels out of the Directory Browse dialog, the directory variable remains blank. The script action then tries to create a substring from an empty string, resulting in the error message.
The solution is to check whether the directory variable has been populated before the substring is created. The following code should be sufficient:
Code:
if (directory != null) {
var length = String.length(directory)
directory = directory.substring(0,length-1)
}
This checks to see if the directory variable is NOT null. If so, the substring is created. If the directory variable IS null, no actions take place.
I hope this helps. Please do not hesitate to contact me if you have any further queries.
Kind regards,