Search code examples
tally

How to limit nested fields in Tally XML Export Response


<ENVELOPE>
<HEADER>
<VERSION>1</VERSION>
<TALLYREQUEST>Export</TALLYREQUEST>
<TYPE>Collection</TYPE>
<ID>Vouchers</ID>
</HEADER>
<BODY>
<DESC>
<STATICVARIABLES>
<SVEXPORTFORMAT>$$SysName:XML</SVEXPORTFORMAT>
<SVCURRENTCOMPANY>CompanyName</SVCURRENTCOMPANY>
<SVFROMDATE TYPE="Date">01-01-2023</SVFROMDATE>
<SVTODATE TYPE="Date">01-01-2023</SVTODATE>
</STATICVARIABLES>
<TDL>
<TDLMESSAGE>
<COLLECTION ISMODIFY="No" ISFIXED="No" ISINITIALIZE="No" ISOPTION="No"
ISINTERNAL="No" NAME="Vouchers">
<TYPE> Vouchers : VoucherType</TYPE>
<CHILDOF>$$VchTypeSales</CHILDOF>
<BELONGSTO>Yes</BELONGSTO>
<NATIVEMETHOD>DATE</NATIVEMETHOD>
<NATIVEMETHOD>VOUCHERTYPENAME</NATIVEMETHOD>
<NATIVEMETHOD>ENTEREDBY</NATIVEMETHOD>
<NATIVEMETHOD>PARTYLEDGERNAME</NATIVEMETHOD>
<NATIVEMETHOD>VOUCHERNUMBER</NATIVEMETHOD>
<NATIVEMETHOD>ALLLEDGERENTRIES.LIST:LEDGERNAME</NATIVEMETHOD>
<NATIVEMETHOD>ALLLEDGERENTRIES.LIST:INVENTORYALLOCATIONS.LIST:STOCKITEMNAME</NATIVEMETHOD>
</COLLECTION>
</TDLMESSAGE>
</TDL>
</DESC>
</BODY>
</ENVELOPE>

I want to limit the fields in the response against above mentioned XML request, I am successfully able to do it for direct voucher fields but unable to get only "LedgerName" field under the ALLLEDGERENTRIES.LIST and "StockItemName" field under the INVENTORYALLOCATIONS.LIST.

When I send request to tally with the mentioned body it returns all the fields under ALLLEDGERENTRIES.LIST as well as INVENTORYALLOCATIONS.LIST.


Solution

  • Its little complicated,

    we need to create a new Report to achieve this.

    I tried to restrict child fields but didn't find a way without creating custom report.

    I will provide sample custom voucher report. with minimal fields, if you want more fields, you can customize it.

    Input XML

    <ENVELOPE>
    <HEADER>
        <VERSION>1</VERSION>
        <TALLYREQUEST>EXPORT</TALLYREQUEST>
        <TYPE>DATA</TYPE>
        <ID>TC_VOUCHER</ID>
    </HEADER>
    <BODY>
        <DESC>
            <STATICVARIABLES>
                <SVEXPORTFORMAT>$$SysName:xml</SVEXPORTFORMAT>
            </STATICVARIABLES>
            <TDL>
                <TDLMESSAGE>
                    <REPORT ISMODIFY="NO" ISFIXED="NO" ISINITIALIZE="NO" ISOPTION="NO" ISINTERNAL="NO" NAME="TC_VOUCHER">
                        <FORM>TC_VOUCHER</FORM>
                    </REPORT>
                    <FORM ISMODIFY="NO" ISFIXED="NO" ISINITIALIZE="NO" ISOPTION="NO" ISINTERNAL="NO" NAME="TC_VOUCHER">
                        <PART>TC_VOUCHER</PART>
                         <XMLTAG>Voucher.LIST</XMLTAG>
                    </FORM>
                    <PART ISMODIFY="NO" ISFIXED="NO" ISINITIALIZE="NO" ISOPTION="NO" ISINTERNAL="NO" NAME="TC_BASETALLYOBJECT">
                        <LINE>TC_BASETALLYOBJECT</LINE>
                        <REPEAT>TC_BASETALLYOBJECT:TC_BASETALLYOBJECTCOLLECTION</REPEAT>
                        <SCROLLED>Vertical</SCROLLED>
                    </PART>
                    <PART ISMODIFY="NO" ISFIXED="NO" ISINITIALIZE="NO" ISOPTION="NO" ISINTERNAL="NO" NAME="TC_TALLYOBJECT">
                        <LINE>TC_TALLYOBJECT</LINE>
                        <REPEAT>TC_TALLYOBJECT:TC_TALLYOBJECTCOLLECTION</REPEAT>
                        <SCROLLED>Vertical</SCROLLED>
                    </PART>
                    <PART ISMODIFY="NO" ISFIXED="NO" ISINITIALIZE="NO" ISOPTION="NO" ISINTERNAL="NO" NAME="TC_VOUCHER">
                        <LINE>TC_VOUCHER</LINE>
                        <REPEAT>TC_VOUCHER:TC_VOUCHERCOLLECTION</REPEAT>
                        <SCROLLED>Vertical</SCROLLED>
                    </PART>
                    <PART ISMODIFY="NO" ISFIXED="NO" ISINITIALIZE="NO" ISOPTION="NO" ISINTERNAL="NO" NAME="TC_VOUCHERLEDGER">
                        <LINE>TC_VOUCHERLEDGER</LINE>
                        <REPEAT>TC_VOUCHERLEDGER:ALLLEDGERENTRIES</REPEAT>
                        <SCROLLED>Vertical</SCROLLED>
                    </PART>
                    <LINE ISMODIFY="NO" ISFIXED="NO" ISINITIALIZE="NO" ISOPTION="NO" ISINTERNAL="NO" NAME="TC_BASETALLYOBJECT">
                        <FIELDS>TC_GUID</FIELDS>
                        <XMLTAG>BASETALLYOBJECT</XMLTAG>
                    </LINE>
                    <LINE ISMODIFY="NO" ISFIXED="NO" ISINITIALIZE="NO" ISOPTION="NO" ISINTERNAL="NO" NAME="TC_TALLYOBJECT">
                        <FIELDS>TC_ALTERID,TC_MASTERID</FIELDS>
                        <XMLTAG>TALLYOBJECT</XMLTAG>
                        <USE>TC_BASETALLYOBJECT</USE>
                    </LINE>
                    <LINE ISMODIFY="NO" ISFIXED="NO" ISINITIALIZE="NO" ISOPTION="NO" ISINTERNAL="NO" NAME="TC_VOUCHER">
                        <FIELDS>TC_DATE,TC_VOUCHERTYPE,TC_VOUCHERNUMBER</FIELDS>
                        <XMLTAG>VOUCHER</XMLTAG>
                        <EXPLODE>TC_VOUCHERLEDGER:Yes</EXPLODE>
                        <USE>TC_TALLYOBJECT</USE>
                    </LINE>
                    <LINE ISMODIFY="NO" ISFIXED="NO" ISINITIALIZE="NO" ISOPTION="NO" ISINTERNAL="NO" NAME="TC_VOUCHERLEDGER">
                        <FIELDS>TC_LEDGERNAME,TC_AMOUNT</FIELDS>
                        <XMLTAG>ALLLEDGERENTRIES.LIST</XMLTAG>
                    </LINE>
                    <FIELD ISMODIFY="NO" ISFIXED="NO" ISINITIALIZE="NO" ISOPTION="NO" ISINTERNAL="NO" NAME="TC_GUID">
                        <SET>$GUID</SET>
                        <XMLTAG>GUID</XMLTAG>
                    </FIELD>
                    <FIELD ISMODIFY="NO" ISFIXED="NO" ISINITIALIZE="NO" ISOPTION="NO" ISINTERNAL="NO" NAME="TC_ALTERID">
                        <SET>$AlterId</SET>
                        <XMLTAG>ALTERID</XMLTAG>
                    </FIELD>
                    <FIELD ISMODIFY="NO" ISFIXED="NO" ISINITIALIZE="NO" ISOPTION="NO" ISINTERNAL="NO" NAME="TC_MASTERID">
                        <SET>$MasterId</SET>
                        <XMLTAG>MASTERID</XMLTAG>
                    </FIELD>
                    <FIELD ISMODIFY="NO" ISFIXED="NO" ISINITIALIZE="NO" ISOPTION="NO" ISINTERNAL="NO" NAME="TC_DATE">
                        <SET>$Date</SET>
                        <XMLTAG>DATE</XMLTAG>
                    </FIELD>
                    <FIELD ISMODIFY="NO" ISFIXED="NO" ISINITIALIZE="NO" ISOPTION="NO" ISINTERNAL="NO" NAME="TC_VOUCHERTYPE">
                        <SET>$VOUCHERTYPENAME</SET>
                        <XMLTAG>VOUCHERTYPENAME</XMLTAG>
                    </FIELD>
                    <FIELD ISMODIFY="NO" ISFIXED="NO" ISINITIALIZE="NO" ISOPTION="NO" ISINTERNAL="NO" NAME="TC_VOUCHERNUMBER">
                        <SET>$VoucherNumber</SET>
                        <XMLTAG>VOUCHERNUMBER</XMLTAG>
                    </FIELD>
                    <FIELD ISMODIFY="NO" ISFIXED="NO" ISINITIALIZE="NO" ISOPTION="NO" ISINTERNAL="NO" NAME="TC_LEDGERNAME">
                        <SET>$LEDGERNAME</SET>
                        <XMLTAG>LEDGERNAME</XMLTAG>
                    </FIELD>
                    <FIELD ISMODIFY="NO" ISFIXED="NO" ISINITIALIZE="NO" ISOPTION="NO" ISINTERNAL="NO" NAME="TC_AMOUNT">
                        <SET>$AMOUNT</SET>
                        <XMLTAG>AMOUNT</XMLTAG>
                    </FIELD>
                    <COLLECTION ISMODIFY="NO" ISFIXED="NO" ISINITIALIZE="NO" ISOPTION="NO" ISINTERNAL="NO" NAME="TC_VOUCHERCOLLECTION">
                        <TYPE>VOUCHERS</TYPE>
                        <NATIVEMETHOD>ALTERID</NATIVEMETHOD>
                        <NATIVEMETHOD>ALLLEDGERENTRIES.LEDGERNAME</NATIVEMETHOD>
                    </COLLECTION>
                </TDLMESSAGE>
            </TDL>
        </DESC>
        </BODY>
     </ENVELOPE>
    

    OuputXML

    <VOUCHER.LIST>
        <VOUCHER>
            <GUID>52889497-5b6b-403d-8f83-224e3c7759b4-00001484</GUID>
            <ALTERID>8816</ALTERID>
            <MASTERID>5252</MASTERID>
            <DATE>1-Apr-23</DATE>
            <VOUCHERTYPENAME>Sales</VOUCHERTYPENAME>
            <VOUCHERNUMBER>1</VOUCHERNUMBER>
            <ALLLEDGERENTRIES.LIST>
                <LEDGERNAME>ABCD India Pvt Ltd</LEDGERNAME>
                <AMOUNT>35,070.00</AMOUNT>
            </ALLLEDGERENTRIES.LIST>
            <ALLLEDGERENTRIES.LIST>
                <LEDGERNAME>Sales</LEDGERNAME>
                <AMOUNT>35,070.00</AMOUNT>
            </ALLLEDGERENTRIES.LIST>
        </VOUCHER>
    </VOUCHER.LIST>
    

    Note: This XML is generated through TallyConnector and uses object orientation(Voucher Extends BaseTallyObject) which is also supported in TDL and AutoTDL generation from C# class feature is not released to public.