web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

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

SQL query to fetch Taxcode based on Voucher

(0) ShareShare
ReportReport
Posted on by 177

Hi there, am trying to develop an SQL query to fetch TaxCode (TaxTrans.Taxcode) based on voucher (SubLedgerVouchergeneralJournalEntry.Voucher) as per my requirement.  I cant able to find the relation between these 2 tables. Initially i tried joining with voucher but then the query fetching duplicate values which is not as expected. Pls suggest the needful to fetch Taxcode based on voucher. If there are multiple Taxcodes attched to an voucher, we need to fetch all the taxcodes accordingly. Thanks in advance. 

I have the same question (0)
  • Suggested answer
    Gunjan Bhattachayya Profile Picture
    35,423 on at

    Hi Prem,

    TaxTrans has a relation defined to SubLedgerVoucherGeneralJournalEntry. You can use this in the SQL query.

    pastedimage1645183738936v1.png

  • PK69 Profile Picture
    177 on at

    Hi Gunjan, I had already tried adding that relation in the Query but it was returning duplicate values as well. In TaxTrans table Recid is the primary index so I was looking to call taxtrans based on recid relation but I couldn't able to do so

  • Gunjan Bhattachayya Profile Picture
    35,423 on at

    Could you please share the query you tried? And a few examples of the duplicate values you are getting.

  • PK69 Profile Picture
    177 on at

    Here am attaching the screenshots of the Query executions with results

    Case 1 : when i execute the SQL query (Lines 1,2,3,4) i can see total 131 rows

    pastedimage1645185606931v1.png

    case 2 :  when i execute Line 3 only the SUBLEDGERVOUCHERGENERALJOURNALENTRY table, i can see only 116 records.

    pastedimage1645185722834v2.png

    So ultimately my requirement is if any Sales Tax code was attached to voucher then i need to fetch that Tax Code Value. So case1 should also fetch 116 but in return its fetching 131. 

  • Gunjan Bhattachayya Profile Picture
    35,423 on at

    The query looks right. If it returns 131 records, not all the records are getting duplicated. Have you tried to identify the voucher numbers of the duplicated records and checked the origin of the transactions?

  • PK69 Profile Picture
    177 on at

    Hi Gunjan, I think its not about the duplicate records, I think its about the relation we are calling the TaxTrans.   I am looking for a relation to call TaxTrans based on TaxTrans.RecId. Pls Suggest accordingly

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > Finance | Project Operations, Human Resources, AX, GP, SL

#1
Martin Dráb Profile Picture

Martin Dráb 544 Most Valuable Professional

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 450 Super User 2025 Season 2

#3
Sohaib Cheema Profile Picture

Sohaib Cheema 250 User Group Leader

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans