cancel
Showing results for 
Search instead for 
Did you mean: 

split function not working for punctuation mark?

e-no91
Champ in-the-making
Champ in-the-making
I have this code in my js script to run when a rule is triggered.

var docName = (document.name).toString();
var name = docName.split(".");
logger.log(docName);
logger.log(name[0]);


The document name is "Testfrom muatturun - Copy (7).txt"

I expected the split function to return name[0] as "Testfrom muatturun - Copy (7)".
But it returns "undefined" instead.

What is the correct way to do this?

Thank you in advance!
2 REPLIES 2

niketapatel
Star Contributor
Star Contributor
Hi

(document.name).toString(); - Its type is object

Try this way



var docName = String(document.name); //convert to String
var name = docName.split(".");


e-no91
Champ in-the-making
Champ in-the-making
Thank you so much!

I totally forgot about object type.

I didn't use String(document.name), I used (document.properties.name).toString() instead.
Getting started

Tags


Find what you came for

We want to make your experience in Hyland Connect as valuable as possible, so we put together some helpful links.