[Solved] CDR UserField

FreePBX 2.7.0.2 box running Asterisk 1.6.2.8

I have a need to add data into the CDR’s userfield whenever users place outbound calls.

cdr_mysql.conf:
[global]
hostname = localhost
dbname=asteriskcdrdb
password = **********
user = *********
userfield=1
;port=3306
;sock=/tmp/mysql.sock

I found one post where someone said to make sure from-pstn-custom was included into the from-pstn context and create the following in extensions_custom.conf:

[from-pstn-custom]
exten => s,n,Set(CDR(userfield)=TEST)

When that didn’t work, I changed it to:

[from-pstn-custom]
exten => s,n,SetCDRUserField(TEST)

That didn’t work either.

I did verify that extensions_custom.conf is being included in extensions.conf

I can’t even verify that the Set(CDR()) command is even running.

Any help or direction you can give would be much appreciated.

The accountcode variable changed in Asterisk 1.6. ${ACCOUNTCODE} has been depricated and replaced with ${CDR(accountcode)}.

My fix:

(1) I copied macro-dialout-trunk into extensions_override_freepbx.conf.
(2) As the second step in the macro, I added “exten => s,n,Set(CDR(userfield)=${CDR(accountcode)})”
(3) Reloaded Asterisk and tested.

I’ve figured out how to get the userfield populated by copying a context or macro to extensions_override_freepbx.conf and modifying it there. So I know the settings for userfield and everything are finally correct.

The next step in getting this problem resolved is figuring out which macro(s) I need to modify to set userfield to account code plus some additional data.

I’ve been trying to trace this down for a day now. Ideas?