In the developer console this works fine:
String op1 = '12345';
String op2 = '1234';
Boolean tmpResult = true;
system.debug('op1: '+op1+', op2: ' +op2+', tmpResult: ' +tmpResult );
tmpResult = op1.contains(op2) ? true : false;
system.debug('op1: '+op1+', op2: ' +op2+', tmpResult: ' +tmpResult );
*USER_DEBUG [14]|DEBUG|op1: 12345, op2: 1234, tmpResult: true*
*USER_DEBUG [16]|DEBUG|op1: 12345, op2: 1234, tmpResult: true*
However, in the Salesforce debug log:
18:15:15.0 (329852706)|USER_DEBUG|[926]|DEBUG|op1: “12345”, op2: “1234”, tmpResult: true
18:15:15.0 (329862345)|STATEMENT_EXECUTE|[927]
18:15:15.0 (329878427)|HEAP_ALLOCATE|[927]|Bytes:5
18:15:15.0 (329886433)|VARIABLE_ASSIGNMENT|[927]|tmpResult|false
18:15:15.0 (329892809)|STATEMENT_EXECUTE|[928]
18:15:15.0 (329901057)|HEAP_ALLOCATE|[928]|Bytes:5
18:15:15.0 (329912132)|HEAP_ALLOCATE|[928]|Bytes:43
18:15:15.0 (329920824)|USER_DEBUG|[928]|DEBUG|op1: “12345”, op2: “1234”, tmpResult: false
18:15:15.0 (329932369)|STATEMENT_EXECUTE|[957]
18:15:15.0 (329934421)|STATEMENT_EXECUTE|[958]
18:15:15.0 (329937300)|HEAP_ALLOCATE|[958]|Bytes:5
18:15:15.0 (329944944)|VARIABLE_ASSIGNMENT|[958]|result|false
After the line 927 tmpResult = op1.contains(op2) ? true : false;
, it turns false. The only clue I have is that it returns true if the value is exact same.
I tried tmpResult = op2.contains(op1) ? true : false;
, the result is same - only true when it is exact value.
tmpResult = op2.contains(op1) ? true : false;
is the same as justtmpResult = op2.contains(op1)
. A Boolean value is already a Boolean value, which is what.contains
returns.op1 = op1.replaceAll('"', ''); op2 = op2.replaceAll('"', '');
, but it only works for developer console. In the debug log, system debug still shows the quotes and it still return false