How to compare Group of check boxes to pick list vales

Posted by Sudhakar on 19-Aug-2014 16:31

Hi all,
I need to check values in two fields if both does not match return false.
field1: States Traveled(Group of check boxes) 

field2: Current State(pick list)

Data::

States Traveled=Arizona,California,Colorado,Florida

Current State=Nevada

Im trying below 

if("{!states_Traveled#code}" !="{!Current_State#code}")
{
return "false";
}

But not working,
Kindly help me how to return false if both values in fields does not match

All Replies

Posted by Godfrey Sorita on 19-Aug-2014 16:57

Hi Sudhakar,

Did you write the code on a formula field? If yes, please make sure to set the formula's return type to String. You also need to assign the same values and integration code to both fields. Please see example below:

The formula should already work once this is done. However, your code will only return false if the value of the 2 fields are exactly the same.

Regards,

Godfrey

Posted by Sudhakar on 19-Aug-2014 17:08

actually i need to validate those two fields in specific pages,if any user try to changes any one of those fields then it needs to validate.that why im planning to take validate record data trigger,kindly let me know what i need to do.

For example=if current state = states traveled then return "you already traveled the state"

Posted by Godfrey Sorita on 19-Aug-2014 17:26

Do you want to check if the current state is one of the states traveled? If that's the case you may use the code below to your validation trigger.

if ("{!states_traveled#code}".indexOf("{!current_state#code}") > -1) {
  return "You already traveled the state";
}

Posted by Sudhakar on 19-Aug-2014 17:39

ty for quick response,how can i check not matching conditions

ex:if current state != states traveled

return "you have not traveled the current state";

Posted by Godfrey Sorita on 19-Aug-2014 17:59

It can be checked by creating or updating records('Before Create' and 'Before Update' should be checked in the validation trigger).

For example, setting the current state to [Nevada] and states traveled to [Arizona,California,Colorado] should not display any error.

Godfrey

This thread is closed