Uniqueid question

Greetings, I hope everyone is well, I need some help.

Let’s assume that I already have a call set (SIP / IAX / DAHDI) and it has the uniqueid = 4444444444444, at that moment I execute a custom application with *1
When this application is executed it does it with a uniqueid different from the call in progress, how can I force the custom application to have the same id of the current call?

If you are talking about the ${UNIQUEID} variable , I dont think you can change it , without a source code modification, that variable is created automatically by Asterisk. The UNIQUEID is in the form of 1267568856.11, where 1267568856 is the Unix epoch, and 11 shows that this is the eleventh call on the Asterisk system since it was last restarted.

Also what do you mean with custom application ?

are you talking about Custom Dynamic Features ?

Calls don’t have Asterisk unique IDs. What has a unique ID is the an instance of an Asterisk channel data structure. For a simple call, one instance is created when the call arrives, and another instance is created by the Dial application.

Certain operations, e…g unparking also create new channel instances and throw away the old one (more accurately, the old one is turned into a zombie and is thrown away by the thread that owns it.

Recent versions of Asterisk do associate one of the unique IDs with the call itself, but this goes under another name. and the rules for determining when to set and change it may not meet your needs.

All Asterisk unique IDs should be treated as opaque, i.e. your dialplan and applications should not make use of the fact that they are, currently, constructed from a time and a serial number.

1 Like

ok, thanks for your time and help

for example i have a call A and on the call i hit *1 and i run a custom dialplan or app on the cel.conf for login channels events, i can see two uniqueid

first uniqueid is the the id of the current call
second unique is the id of the *1 app/dialplan

my question is who asterisk can associate the uiqueid from the current open channel whit the execute app/dialplan? in the same database record?

The question is because this uniqueid change generates two different CDRs and I want to be able to associate the CDR of the current call with the application CDR executed with * 1

A workaround would be use a global variable which hold the value of the ${UNIQUE ID} variable for the channel who made the call , and then save the value of such variable on the userfield column for each CDR record

thanks ambiorixg12 where i can find and example and documentation about this?

Would be something like this

same=>n,Set(GLOBAL(MYGLOBALVAR)=${UNIQUEID})

same=>n,set(CDR(userfield)=${MYGLOBALVAR})

https://wiki.asterisk.org/wiki/display/AST/Global+Variables+Basics

https://wiki.asterisk.org/wiki/display/AST/Asterisk+13+Function_CDR

Could be possible you need to use CHANNEL function instead of CDR

Ok, thanks for your time and help :slight_smile: