Accountcode field - where is it used?

Other than as a data point added to CDR - is the accountcode used anywhere else in FreePBX?

Not really, it’s there for CDRs.

1 Like

It’s kind of a baz variable in the CDR. You can use it for anything you want and use it cull out certain calls.

For example - let’s say you do the “two agents, one credit card” thing. One agents sets up the sale the other agent processes the credit card, but your system is set up to record all calls. You could (and remember, I’m making this example up as I got) set up the call stream so that the accountcode gets set “dynamically” when the agent puts in an in-call feature code. At the end of the day, any calls with that account code get their recordings deleted.

I can think of lots of places where it would be useful (fiduciary validation, stuff like that) but most people don’t need it or use it very much.

99% sure that when the pinsets pro option to record the pin in CDR, the accountcode field is used for that.

Don’t forget that since Asterisk 12 there is now the peercode which would hold the accountcode for channel 2 (party b) if the accountcode was set on that channel.

Thanks. My intention is to use the field in the GUI to store an identifier in the astdb for reference later (with a script). Since I’m not using pinsets on this system I think this will work well.

1 Like

If not already in use, consider userfield as well.

2 Likes

I don’t see where that is entered in the GUI. Being able to update it from the GUI (ideally, the Extensions module) is necessary.

I see what you’re doing now. That’s pretty clever, I have often needed to have the ability to define custom parameters for each extension, but it never occurred to me that I might repurpose the accountcode field for this. Totally stealing this idea.

edit 3 years later - with the addition of the JSON_DECODE function in Asterisk, you can store multiple key → values pairs in this field in JSON format, then parse out what you need when you need it.

3 Likes

I’m not stealing it now as I don’t have an immediate need, but I am absolutely filing that in the need to remember drawer.

Bill, thank you so much for bringing up this idea!

So simple and can do so much.

For example, I just did an extension to extension block/allow based on the account code.

Basically, with COS you can control everything besides calls between extension to extension. We managed in the past to block extension to extension calls based on the Caller ID etc. But now we can have the PBX administrator simply add the account code to each extension, and only extensions with matching account codes can call each other.

[macro-dialout-one-predial-hook]
exten => s,1,noop(Entereing custom context to block/allow ext to ext calls based on the account code)
exten => s,n,Set(CALLER_ACCOUNTCODE=${DB(AMPUSER/${AMPUSER}/accountcode)})
exten => s,n,ExecIf($["${CALLER_ACCOUNTCODE}" = "${CALLEE_ACCOUNCODE}"]?MacroExit:Goto(app-blackhole,zapateller,1))
exten => s,n,Hangup

This dialplan can probably be brushed up a little, but it works…

3 Likes

This topic was automatically closed 31 days after the last reply. New replies are no longer allowed.