Unsolved
This post is more than 5 years old
11 Posts
0
700
if statement with OR
Hi,
I'm trying to get if statement to compare against mutiple strings in one statement but it is failing for some reason. (Verified the statement to be working seperately without using || )
deviceObj = object(eventObj->OccurredOn);
if (!deviceObj->isNull()){
if (deviceObj->PrimaryOwnerContact == "P2" || deviceObj->PrimaryOwnerContact == "P2test " ){
eventObj->Severity = 2;
eventObj->changed();
}
although the following works fine
deviceObj = object(eventObj->OccurredOn);
if (!deviceObj->isNull()){
if (deviceObj->PrimaryOwnerContact == "P2" ){
eventObj->Severity = 2;
eventObj->changed();
}
any suggestion?
PaulORourke
170 Posts
0
April 2nd, 2015 01:00
Hi knakawa,
Your code looks good and I tested it in my environment just to double check and it worked as expected.
I believe the issue maybe that you have an extra space after P2test:
PrimaryOwnerContact == "P2test "
This is probably not matching the PrimaryOwnerContact value.
Can you please re-try the script as follows:
deviceObj = object(eventObj->OccurredOn);
if (!deviceObj->isNull()){ if (deviceObj->PrimaryOwnerContact == "P2" || deviceObj->PrimaryOwnerContact == "P2test" ){
eventObj->Severity = 2;
eventObj->changed();
}
Let me know how this goes. Thanks,
Kind Regards,
Paul O'Rourke