The CreatorCon Call for Content is officially open! Get started here.

Regular expression parse works in business rule but not in workflow

oharel
Kilo Sage

Hi all,

A little help please:

I have a catalog item variable (group) with the following value: 10:marketing

I am trying get the number (10) from the variable.

When running an after update business rule on the requested item, the number is returned properly. When running the exact same lines from a workflow activity,  "undefined" is returned. The WF is a "run script" activity and is placed after the first approval (so it is way after the ritm is created).

The script:

var streamnumber = current.variables.group;
var num = streamnumber.match(/(.*)\:/).pop(); //this gets the number before the : 
gs.addInfoMessage('hbs --> num ' + num);

Can't see any special logs with errors or warning...

Your thoughts,

harel

1 ACCEPTED SOLUTION

Dubz
Mega Sage

Hi Harel,

It might be worth adding a getValue() on the end of the streamnumber variable. I just tested this on a glide record and it seemed to do the trick. 

var streamnumber = current.variables.group.getValue();

Cheers

Dave

View solution in original post

3 REPLIES 3

Dubz
Mega Sage

Hi Harel,

It might be worth adding a getValue() on the end of the streamnumber variable. I just tested this on a glide record and it seemed to do the trick. 

var streamnumber = current.variables.group.getValue();

Cheers

Dave

So... awesome. I thought it had to do something with the way the value is retrieved, but could not figure out what.

Thanks.

h

Yeah, without the getValue it's just a pointer to a glide object, hence the undefined. It's more common to see this on glide records as opposed to when using the current object, must be something to do with how the current object is accessed in the workflow context.