Search code examples
xmlrestsoaptally

Export stock item with autosuggestion of item name/part number from tally using xml tag


I am trying to fetch stock item from TallyErp 9. I am able to get particular item details using xml tags but now I require item should come same as that of Tally,i.e on entering search param it should give all stock item related to my search keyword. My Current code to fetch single stock item details is as follows:

`

<?xml version=1.0 encoding=UTF-8>
  <ENVELOPE>
      <HEADER>
        <VERSION>1</VERSION>
        <TALLYREQUEST>EXPORT</TALLYREQUEST>
        <TYPE>OBJECT</TYPE>
        <SUBTYPE>stock item</SUBTYPE>
        <ID TYPE="Name">`+ searchValue + `</ID>
      </HEADER>
      <BODY>
          <DESC>
            <STATICVARIABLES>
               <SVEXPORTFORMAT>$$SysName:XML</SVEXPORTFORMAT>
            </STATICVARIABLES>
            <FETCHLIST>
               <FETCH>OpeningValue</FETCH>
               <FETCH>OpeningRate</FETCH>
               <FETCH>OpeningBalance</FETCH>
               <FETCH>ClosingBalance</FETCH> 
               <FETCH>ClosingRate</FETCH> 
               <FETCH>STANDARDPRICELIST.RATE</FETCH>
           </FETCHLIST>
       <TDL>
         <TDLMESSAGE>
           <OBJECT NAME="stock item" ISINITIALIZE="Yes">
          </OBJECT>
         </TDLMESSAGE>
      </TDL>
        </DESC>
      </BODY>
    </ENVELOPE></xml>

`

Here I am passing searchValue from input box and getting all request successfully. Looking forward some answers which can really help me.

Thanks in advance.


Solution

  • This XML request retrieves all stockitem names from Tally ERP 9 wherein the StockItem Name starts with 'My Item' or the StockItem Alias starts with 'My Item'.

    Example: My Item1 (Name starts with My Item)
    My Item2 (Name starts with My Item)
    ABC (Alias starts with My Item)

    As you can see, even though the third StockItem Name is 'ABC', it is returned by the query as the Alias starts with 'My Item'

    Here's the XML request :

    <ENVELOPE>
      <HEADER>
        <TALLYREQUEST>Export Data</TALLYREQUEST>
      </HEADER>
      <BODY>
        <EXPORTDATA>
          <REQUESTDESC>
            <REPORTNAME>ODBC Report</REPORTNAME>
            <SQLREQUEST Type='General' Method='SQLExecute'>Select $Name from StockItem where $Name like 'My Item%' or $$Alias like 'My Item%'</SQLREQUEST>
            <STATICVARIABLES>
              <SVEXPORTFORMAT>$$SysName:XML</SVEXPORTFORMAT>
            </STATICVARIABLES>
          </REQUESTDESC>
          <REQUESTDATA/>
        </EXPORTDATA>
      </BODY>
    </ENVELOPE>
    

    References : https://www.rtslink.com