Ami & callerid

Hello, just to ask is this right syntax for getting callerid?

$callerid = $ami->GetVar($channel,‘CALLERID’);

I got response with Value null. :S
Is there different way for this? Can you advice me how to get callerid ?

Thank you
Anya

The best way is probably to capture it from the events.

Have you tried adding (), or (num)?

If all else fails, copy the caller ID to a local variable, within the dialplan, itself.

It is working with num:) Thank you !
Can I also on this way get DNID number? Is there dnid variable??

core show function CALLERID

I’ve not investigated to what extent DNID is maintained, you may have to set it in the dialplan, from the initial ${EXTEN}, in some cases.

Ok, If I set dnid in the dialplan, how can I get it using AMI? There is no other option?
I have A number that is calling B number, and B number forward call to C number. I want to C number see the B number, not A …if you understand me:)

That will depend on how the transfer is done. You may need to read specific channel variables. Asterisk may not know a transfer is in progress at the time that you try to get the information.

If dnid is set, reading CALLERID(dnid) should return the value, however I’m not sure how Asterisk manipulates this.

CALLERID(dnid) is excatly what I needed. Thanks a lot on your advices and time !

Best regards,
Anya

I have a suspicion that CALLERID(dnid) is only automatically handled on ISDN incoming and outgoing calls, and you must explicitly manipulate, or access, it in the dialplan, on all other contexts.

I got dnid, using just GetVar :

Array
(
[Response] => Success
[Variable] => CALLERID(dnid)
[Value] => XXXXXXXXXXXX
)