cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Is not a function error

Ludovic_MOOS
Participant
0 Likes
2,550

Hi,

I've been facing an issue for quite a long time now, which I've always managed to bypass so far but it has become so critical it really blocks my project now. Let me explain:

I created a custom script containing a regular expression, the activity (#29) works well and generates a proper output (a 2 or 3 digit number):

However, each time I add another custom script right after an existing custom script (selecting the previous custom script output as input: what I'm trying to do here is to "clean" the previous custom script output in case it contains unwanted characters) and I run the automation, the second custom script results in the following error message "input.match is not a function" (note that both custom script activities have the same kind of function: return input.match(MyRegex);):

In the above screenshots, the first custom script is part of a Try/Catch Control, but even when not using a Try/Catch control, the second custom script always results in the same kind of error message "input.match is a not a function", whereas both regex work fine and each custom script performs well when "standing alone".

What am I missing here? Does anyone have a clue?

Thanks for your help.

Best regards,

LM.

View Entire Topic
TJe
Product and Topic Expert
Product and Topic Expert
0 Likes

Could not reproduce the issue with a simple example.
Can you try to have both calls in just one custom script ?

Ludovic_MOOS
Participant
0 Likes

Hi thomas.jentsch,

Thanks for your answer. Can you share your example please? Because I've also tried with a basic automation (2 consecutive custom scripts with return input.match(MyRegex); functions) and it still does not work on my side. I really don't see how I could do it any differently...

Thanks,

LM.

TJe
Product and Topic Expert
Product and Topic Expert
0 Likes

Guess come closer to the problem now.
I'm not an expert of regular expression, but seems that match() returns an array and not a string.
Here a sample with an empty regular expression:

var a = input.match();return a[0].match();

If you want to return a string, you need to return the first element from the array.
And here you can add the second match() already.

Ludovic_MOOS
Participant
0 Likes

thomas.jentsch,

I always had a feeling about this array thing but never managed to figure it out 😉 It seems to be running well when I change the function of my 2nd custom script for return[0].match(MyRegex);

Thanks for the lead and help.

Best regards,

LM.