finding a particular value in a specified related record

I reailize this is a very simple concept, but I am am not getting the expected results.

I have a method that searches a particular related record / field for a specific values. If the argument is true, I want to return a value. In the following method, I keep getting ‘3’, no matter what values are present or no values at all.

//Insertion Tube Repairs
elements.Order_Line_Items.setSelectedIndex(15|16)
if (orders_to_orderlineitems_byorderid.item_code == ‘F0108’,‘F0114’,‘F0206’,‘F0207’,‘F0208’,‘F0209’,‘F0260’,‘F0261’,‘F0294’,‘F0302’,‘F0303’,‘F0307’,‘F0363’,‘F0364’)
{
globals.Integer5 = 1;
}

//Light Guide Tube Replacement Validation
elements.Order_Line_Items.setSelectedIndex(17)
if (orders_to_orderlineitems_byorderid.item_code == ‘F0119’,‘F0280’,‘F0206’,‘F0123’)
{
globals.Integer5 = 2;
}

//Bending Section Rebuild Validation
elements.Order_Line_Items.setSelectedIndex(21)
if (orders_to_orderlineitems_byorderid.item_code == ‘F0226’,‘F0228’,‘F0229’,‘F0227’,‘F0169’,‘F0170’,‘F0173’, ‘F0172’)
{
globals.Integer5 = 3;
}

I am sure I am missing something regarding combining the selected index and the indexed record field (item_code), into a single statement , and run a “else if” statement.

Thanks for any help

You can’t use “==” operator to test for inclusion in a list.

This method works fine though, it checks two different related fields, for serveral different conditions. Is that not the same concept?

//Insertion Tube Repairs
elements.Order_Line_Items.setSelectedIndex(15|16)
if (orders_to_orderlineitems_byorderid.item_code == ‘F0108’,‘F0114’,‘F0206’,‘F0207’,‘F0208’,‘F0209’,‘F0260’,‘F0261’,‘F0294’,‘F0302’,‘F0303’,‘F0307’,‘F0363’,‘F0364’)
{
elements.Order_Line_Items.setSelectedIndex(1)
orders_to_orderlineitems_byorderid.item_cost = 0;
elements.Order_Line_Items.setSelectedIndex(3)
orders_to_orderlineitems_byorderid.item_cost = 0;
elements.Order_Line_Items.setSelectedIndex(12)
orders_to_orderlineitems_byorderid.item_cost = 0;
elements.Order_Line_Items.setSelectedIndex(14)
orders_to_orderlineitems_byorderid.item_cost = 0;
elements.Order_Line_Items.setSelectedIndex(21)
orders_to_orderlineitems_byorderid.item_cost = 0;
elements.Order_Line_Items.setSelectedIndex(23)
orders_to_orderlineitems_byorderid.item_cost = 0;
elements.Order_Line_Items.setSelectedIndex(24)
orders_to_orderlineitems_byorderid.item_cost = 0;
}

I guess Iwill just have to loop through the line items. I was trying to avoid running loops, because when a service order is created, if certian repairs exist, other repairs are included resulting in no charge lines items. This is then validated against contract pricing schemes, that are unique to each account.

I am trying to automate a very complex pricing / service process that has hundreds of scenarios, and am down to the last piece.

Why don’t you use indexOf()?

As in:

var x = orders_to_orderlineitems_byorderid.item_code
if(x.indexOf('F0108,F0114,F0206,F0207,F0208,F0209,F0260,F0261,F0294,F0302,F0303,F0307') != -1) {
  ....YOUR CODE HERE...
}

Does that work?

Excellent, thanks for your help, that is exactley what I need.