"Starts With" condition on Workflow "If" activity not working as expected

bostonsnow
Kilo Guru

Hello,

I have an "If" activity set up on a workflow that I cannot get to work. On my If activity is a "starts with" condition that I'd like to use to identify Select Box variable choices that start with certain text. 

For example:

I have a Select Box variable on a catalog item that is named "Services". This Select Box contains the following choices:

  • Services - Service Category 1 - Service Name 1
  • Services - Service Category 1 - Service Name 2
  • Services - Service Category 1 - Service Name 3
  • Services - Service Category 1 - Service Name 4

Instead of adding an individual "IS" condition for each of these choices I would like to use the "starts with" condition to capture all of the services in Service Category 1. I set up the condition as follows:

Variables - My Catalog Item - Services - starts with - "Services - Service Category 1"

This condition is not working. What am I doing wrong?

Thanks,

Mike

1 ACCEPTED SOLUTION

bostonsnow
Kilo Guru

Hello all,

Apologies for the drop in communication. I was able to get this working using the Condition builder and the Value prefix of the Variable choices.

So in the Condition builder I entered:

Variables - My Catalog Item - Services - starts with - "services__service_category_1"

Thanks so much for all of the input, it's very much appreciated.

Mike

View solution in original post

9 REPLIES 9

I just tried this with my PDI using the option with toString() in it and it worked fine.  What type of variable is it?

bostonsnow
Kilo Guru

It's a Select Box.

ok that is what I used.  Are you looking at the Value of your select box or are you trying to use what the user sees?  When scripting unless you use .getDisplayValue() it will use the value. Below is what I setup for my test variable.  I made my text and value match.  However if your does not you will need to use .getDisplayValue().  In the below screenshot I have put what current.variables.variablename returns in red rectangle. 

find_real_file.png

 

Mike Patel
Tera Sage

try

answer = ifScript();

function ifScript() {
    var sltbox = current.variables.yourvariablename.getDisplayValue();
    if (sltbox.startsWith("Services - Service Category 1")) {
        return 'yes';
    }else{
		return 'no';
	} 
}

 

bostonsnow
Kilo Guru

Hello all,

Apologies for the drop in communication. I was able to get this working using the Condition builder and the Value prefix of the Variable choices.

So in the Condition builder I entered:

Variables - My Catalog Item - Services - starts with - "services__service_category_1"

Thanks so much for all of the input, it's very much appreciated.

Mike