Issue using case statement to evaluate caller ID numbers


#1

1) Give a description of the problem
Case statement is not evaulating correctly due to different variable types.

2) What is the expected behaviour?
The incoming caller ID should be looked up against known values and the callers name should be used when announcing the call

3) What is happening/not happening?
It is messing up the evaluation of the number - integer vs string. Therefore there is never a match

**4) Post a Green Snapshot of the piston![image|45x37]

5) Attach logs after turning logging level to Full
17/06/2020, 22:35:15 +805ms+0ms╔Received event [Home].execute = 82.17.100.34 with a delay of 135ms+141ms║RunTime Analysis CS > 15ms > PS > 73ms > PE > 52ms > CE+144ms║Runtime (45824 bytes) successfully initialized in 73ms (v0.3.110.20191009) (143ms)+145ms║╔Execution stage started+149ms║║Cancelling statement #3's schedules...+156ms║║Executed virtual command setVariable (1ms)+161ms║║Executed virtual command setVariable (1ms)+170ms║║Executed virtual command setVariable (3ms)+173ms║║Evaluating switch with values [[i:29:null:0, v:[t:string, v:441616361646, vt:string]]]+176ms║║Comparison (string) 441616361646 is (integer) -765269842 = false (1ms)+179ms║║Comparison (string) 441616361646 is (string) +441416200816 = false (1ms)


#2

To force an integer, have you tried changing the variable type on line 18 to “integer”…?

Also, have you tried wrapping the arg statement with int()…?

IE: Set variable intNumber = int($args.from)


#3

You could probably use expressions in the case statements and quote the phone numbers so they are strings.


#4

Sorry, I never got a notification of the reply…

It seems to be an issue with the size of the integer…


#5

If you want all 12 digits, this Expression works.
mid("(441216371344)",1,12)
… as seen here:

pic


Alternatively, if you want to strip it down to the last 7 digits, you can use this Expression:
mid("(441216371344)",6,7)
… as seen here:

pic


#6

Magic! That did it

Thanks @WCmore for all your help


#7

Sure thing!

Perhaps you can solution my post above as the solution to help others?


#8

Done!