Skip to main content

Hello

i am trying to extract a part of a string in a JavaScript step in a BPM, but when i do not have any issue with IndexOf method i get the error “Unable to evaluate script while executing activity 'Activity_1uhrh20' in the process definition with id 'e8f99a83-733f-11ee-b992-76d175c7f0d6':TypeError: Selection.substring is not a function in at line number 4” like if substring was not a javascript method (actuall y i test with substr and get the same bad result)

hereunder is my code

var Selection = execution.getVariable("Selection");
var pos_start = Selection.indexOf("RAM_NO=")+7;
var pos_end = Selection.indexOf("^");
var CCN_RmaNo = Selection.substring(pos_start, pos_end);
execution.setVariable("CCN_RmaNo ", CCN_RmaNo );

everything works ok except the line

var CCN_RmaNo = Selection.substring(pos_start, pos_end);

Anyone any idea?

ok i will answer myseelf :)

actually you can use javascript string method ...if you are using a string :)

i was trying string method on a table after figuring that out here is my new script that works

 

var SelectionTab = execution.getVariable("Selection");
var pos_start = SelectionTaba0].indexOf("RMA_NO=") + 7;
var pos_end = SelectionTaba0].indexOf("^");
var CCN_RmaNo = SelectionTaba0].substring(pos_start, pos_end);
execution.setVariable("CCN_RmaNo", CCN_RmaNo );

 

however please nopte that all javascript fucntion are case sensitive so Substring method will not works when substring yes

 

sorry for a stupid post 


@vito Not a stupid post at all, it learned me something.

What I don't understand is your last words '...when substring yes’. What do you mean with that?


hello,

what i mean is that as the javascript function name are case sensitive if you write

var CCN_RmaNo = SelectionTab[0].substring(pos_start, pos_end);

with a lowercase s at begining of substring fucntion name it will works when if you write

var CCN_RmaNo = SelectionTabb0].Substring(pos_start, pos_end);

with a Uppercase S t begining of substring fucntion name it will not works :)

best regards


@vito Thanks for the detailed explanation. Typically something that takes a long time to see when something is not working. 


Reply