Skip to main content
Solved

javascript error with substring in workflow/BPM


Forum|alt.badge.img+7
  • Sidekick (Customer)
  • 13 replies

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?

Best answer by vito

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 = SelectionTab[0].indexOf("RMA_NO=") + 7;
var pos_end = SelectionTab[0].indexOf("^");
var CCN_RmaNo = SelectionTab[0].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 

View original
Did this topic help you find an answer to your question?

4 replies

Forum|alt.badge.img+7
  • Author
  • Sidekick (Customer)
  • 13 replies
  • Answer
  • October 25, 2023

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 = SelectionTab[0].indexOf("RMA_NO=") + 7;
var pos_end = SelectionTab[0].indexOf("^");
var CCN_RmaNo = SelectionTab[0].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 


eqbstal
Superhero (Partner)
Forum|alt.badge.img+21
  • Superhero (Partner)
  • 677 replies
  • November 20, 2023

@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?


Forum|alt.badge.img+7
  • Author
  • Sidekick (Customer)
  • 13 replies
  • November 20, 2023

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 = SelectionTab[0].Substring(pos_start, pos_end);

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

best regards


eqbstal
Superhero (Partner)
Forum|alt.badge.img+21
  • Superhero (Partner)
  • 677 replies
  • November 21, 2023

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


Reply


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings