Skip to main content

Notifications

Community site session details

Community site session details

Session Id :
Finance | Project Operations, Human Resources, ...
Suggested answer

How to link DOCUVALUE table to related business metadata

(0) ShareShare
ReportReport
Posted on by 5

I am trying to pull a report of all the documents referenced in AX, and I'm having a heck of a time figuring out the AX database structure. Ideally I want to pull a list of documents and the Journal / Batch # each is associated with.
In our AX environment, all documents are stored on a share (i.e. they're not actually stored as BLOBs in the AX database).

It looks like the DOCUVALUE table is the principal table that references the documents, having the ORIGINALFILENAME and other columns that seem to "point" to the files on the AX share. But DOCUVALUE doesn't contain any useful business metadata.

After a bit of exploring, it looks like like the DOCUREF table relates to DOCUVALUE (DOCUVALUE.RECID = DOCUREF.VALUERECID) which helps a little - gives you the Company #, but that's about it.

After a bit more exploring, it looked like it would be possible to join across to LEDGERJOURNALTABLE as shown below:

select ljt.journalnum, filename + '.' + filetype filename, ljt.name journal_name,
dr.refcompanyid, convert(varchar(10), ljt.posteddatetime,111) posted_date,
ljt.createdby, convert(numeric, ljt.journaltotalcredit) journalamount
from LEDGERJOURNALTABLE ljt, DOCUREF dr, DOCUVALUE dv
where dv.RECID = dr.VALUERECID and dr.refrecid = ljt.recid
order by 1,2

This looked promising, so I pulled out a data listing and asked one of our key business users to review the results. She indicated that it was accurate to some extent, but there were other areas where the document referenced just didn't have any relation to the JournalNum in the listing.

So - I'm at a bit of a dead end - I've spent further time generating SQL statements to harvest data using specific RECID values, trying other joins, but each time I just disappear down a rabbit hole.

Any ideas? Any help gratefully received!!

  • Suggested answer
    Simon Weekley Profile Picture
    5 on at
    RE: How to link DOCUVALUE table to related business metadata

    Thanks Nikolaos - that's great!!

    I couldn't find a function called tableNum, but I did some poking around and found the table id as follows:

    select NAME , TABLEID

     from SQLDICTIONARY

    where FIELDID = 0

    and name like 'LEDG%JOU%TAB%'

    Put that in to the WHERE clause (and dr.RefTableId = 211) - bingo!

    Looks like much better data!

    Thanks again

  • Suggested answer
    nmaenpaa Profile Picture
    101,158 Moderator on at
    RE: How to link DOCUVALUE table to related business metadata

    You need to limit the DocuRef results by RefTableId as well (dr.RefTableId == tableNum(LedgerJournalTable)). Now you're only using RefRecId as criteria but it returns documents that are related to ANY table where some record has the same RecId than your journal.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

🌸 Community Spring Festival 2025 Challenge 🌸

WIN Power Platform Community Conference 2025 tickets!

Jonas ”Jones” Melgaard – Community Spotlight

We are honored to recognize Jonas "Jones" Melgaard as our April 2025…

Kudos to the March Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 294,120 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 232,871 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,158 Moderator

Leaderboard

Product updates

Dynamics 365 release plans