How to get reports to show DID dialed?

Using FreePBX, and I’ll start off by saying I don’t know a whole lot about this sytem, it was installed by someone and I just maintain it :slight_smile:

Anyway, i go to the “Reports” tab, and try to generate reports - it shows Calldate, channel, source, Clid, Dst, disposition, and duration.

What i’m trying to find is what DID they dialed… we have 8 SIP trunks coming into the box, and 4 or 5 DIDs set up, but I need to try to find out what DID they dialed to connect to us. Is there any way to do that?

Thanks in advance

I provided a patch to display, and be able to search on the user field. The patch should make it into 2.9

You can easily move the DID to the user field in extensions_custom.conf

I will provide an example and post it after the OTTS training seminar.

Here’s one way.

Set up Inbound Routes for each DID. You might already be doing this.

For each one, put a unique identifier in the “CID Name Prefix” field. e.g. the last four digits of the DID and a : . And of course, direct the Inbound Route to where you want the call to go.

Then in your reports, you’ll be able to spot which DID was called using the CID field.

Let’s say you have DIDs 0000, 1111, 2222…

Your call report would show the incoming calls as

0000: Fred <8001234567>
1111: Bob <8002345678>


Also, you’d see this on the phone’s display when the call is coming in, which might be a nice bonus.

I’m looking for this info myself.

Hi SkykingOH:

Did the training go well?

Have you posted the example you mention here anywhere? If so, where could I find it?


I have not worked it out yet. I need to get it working for myself. If you load the patch you will be able to search on channel and user field. I just need to come up with a custom context that moves the DID to the user field and then passes then does a goto to the from-did context preserving the DID in $EXTEN

Thanks for the update. Where would I find this patch you mention? I too have not had time to work on this.

SkyKingOH, have you made any progress ?

None what so ever. Been busier than a one man paper hanger around here.

I really need to get this done too!

A feature request has been filed #5123, please look at it and give feedback. It will probably be included in FreePBX 2.10.

So, what other fields should be included in reports?


Have you had a look at the patch that we submitted a few weeks ago? It uses the existing user field in the CDR. The patch also exposes the DST-channel variable.

Searching is available from both fields now, Philippe indicated to me that needed to be sanity checked and why he did not put in 2.9.

The extension code you have in #5123 should do what I want if it is put in extensions_custom.conf and used as the trunk destination. All I really need to do is format a goto statement to pass back to from-trunk.

How does this look? Robert can you test this with the patch and let me know if it works? Add this to extensions_custom.conf and then put the trunk you want to peg DID info from in the add-userdid context.

exten => s,1,set(CDR(userfield)=${EXTEN}
exten => s,n,goto(from-trunk,s,1)
exten => s,n,hangup()


Hi Scott,
Yes, I did see that, but the problem with using userfield is that it might already be in use as there are numerous posts about how to use it. I know the devs had a discussion some time ago about the userfield.

The correct way to do it is by adding more fields to the db and use the CDR variable to populate the fields.

I am testing it right now for implementation because (CDR(fromdid)=${FROM_DID}) is what a large site wants and they are donating time for it to be implemented.

But without the additional fields in the DB, I am not sure how I am going to get the data…

Robert, that’s what the patch fixes. The patch I submitted displays the user field and exposes both channel fields.