How to solve CallerID crossover? Callee/Caller

I’m having difficult programming features.conf functions based in callerid info.

I have configured a function in features.conf that run a Macro(). That macro checks the CallerID num each time is executed.
If callerid is X do this, if callerid is Y, do this. etc… Check this:

Rob ------->call----------> Manuel
(201) (227)
In this call, Rob is the caller and Manuel is the callee, right? Ok!
So, in that case, the variable: ${CALLERID(num)} should display: 201. Right? Ok!

Now, check this out.
Rob ------->call----------> Manuel ---------> July
(201) (227) (2034)
In this call, Rob is the caller & Manuel is the callee.
Then Manuel transfer the call, so Manuel is now the caller and July is the callee.
So, in that case, the variable: ${CALLERID(num)} will display: 227 and NOT 201.

My question is: How can I keep Rob extension in the callerid without care if the call was transfered or whatever else?

Thanks.

Try using the ASTDB or a variable with scope.

The documentation for feature maps says:

[quote]; IMPORTANT NOTE: The applicationmap is not intended to be used for all Asterisk
; applications. When applications are used in extensions.conf, they are executed
; by the PBX core. In this case, these applications are executed outside of the
; PBX core, so it does not make sense to use any application which has any
; concept of dialplan flow. Examples of this would be things like [color=#FF0000]Macro[/color], Goto,
; Background, WaitExten, and many more.[/quote]

That means you are using macros at your own risk.

The application will be run on the channel that requested the feature. This may be the original callee.

Support questions should be asked on Asterisk Support.