Asterisk: a "reverse" phonebook

I need something like this but for call on exit/outbound.
I have tried by myself

on extensions.conf I put this line in the exit context

[telecom]
exten => _XXXXX.,1,NoOp()
same => n,set(CDR(nome)=${ODBC_Phonebook(${CALLERID(num)})})
...

I reload dialplan and I try to call a number (saved in phonebook table)

but…


select nome from cdr limit 153 offset 877;
+------+
| nome |
+------+
| NULL |
| NULL |
| NULL |
| NULL |
| NULL |
+------+
5 rows in set (0,006 sec)

Any suggestion? Thanks

Solution found. On extensions.conf

same => n,set(CDR(nome)=${ODBC_Phonebook(${CDR(dst)})})

If the name is present in the phonebook will appear in the “nome” custom field.