Get List of Companies via SOAP

Discussion in 'Tally Integration' started by admin, Apr 13, 2012.

    
  1. admin

    admin Administrator Staff Member


    In this example we will use VBScript to retrieve the list of loaded companies in Tally and display it on a web page.

    Tally will respond to well formed XML fragments only. Therefore we need to construct a XML string for sending to Tally. We can construct the XML fragment either by using the DOM of the MS XML parser of writing the entire fragment manually.

    ‘ SOAP request to get list of loaded companies
    Dim strRequestXML ‘ store request XML

    Code:
    strRequestXML = _
    "<ENVELOPE>" & _
    "  <HEADER>" & _
    "    <TALLYREQUEST>Export Data</TALLYREQUEST>" & _
    "  </HEADER>" & _
    "  <BODY>" & _
    "    <EXPORTDATA>" & _
    "      <REQUESTDESC>" & _
    "        <REPORTNAME>List of Companies</REPORTNAME>" & _
    "        <STATICVARIABLES>" & _
    "          <SVEXPORTFORMAT>$$SysName:XML</SVEXPORTFORMAT>" & _
    "        </STATICVARIABLES>" & _
    "    </REQUESTDESC>" & _
    "    </EXPORTDATA>" & _
    "  </BODY>" & _
    "</ENVELOPE>"
    Before sending this request to a remote host, we need to know the IP / domain name and the listening port of Tally. In this example we assume the Tally is running on IP 192.168.1.1, Port 9000.
    Now,Sending data to Tally requires instantiating the ServerXMLHTTP and using Open and Send methods of the component.

    Dim ServerObj
    Set ServerObj = Server.CreateObject ( "Msxml2.ServerXMLHTTP" )
    ServerObj.open "POST", "http://192.168.1.1:9000”, FALSE
    ServerObj.send strRequestXML

    This above code sends the XML request to Tally. To retrieve Tally’s response we do the following

    Dim strResponseXML
    strResponseXML = ServerObj .responseText

    If there are 2 companies currently loaded in Tally - ABC Company and Test Company
    then Tally will respond with the following XML fragment.

    Code:
    <ENVELOPE>
      <COMPANYNAME.LIST>
        <COMPANYNAME>Demo Company</COMPANYNAME>
        <COMPANYNAME>Tally Solutions</COMPANYNAME>
      </COMPANYNAME.LIST>
    </ENVELOPE>
    
    You can now parse this XML to display the list of companies.
     
    zakirhossain_diu likes this.



  2. Query-----> Xml file required to Fetch(export) Ledger Vouchers for a specific
    Ledger.

    Actually I'm a java Developer working in Tally Integration in our product "Invoice Tracker" and new to Tally. If anybody has any idea about the "Query" please replay.
     


  3. divy2281774

    divy2281774 New Member


    how to get access <Company.List> tag from javascript
     


  4. hemant009

    hemant009 New Member


    I want to create update delete operation through XML REST request. Please help.
     


  5. teja varma

    teja varma Active Member


    you can use ajax for that

    Code:
    var xhttp = new XMLHttpRequest();
      xhttp.onreadystatechange = function() {
        if (this.readyState == 4 && this.status == 200) {
         document.write( this.responseText);
        }
      };
      xhttp.open("POST", "http://localhost:9000", true);
      xhttp.send(xml_data);

    please check odbc port in tallyerp9 before making request
     
    Last edited: Jul 24, 2019


  6. teja varma

    teja varma Active Member


    go through the document it will help you
     

    Attached Files:

    zakirhossain_diu likes this.


  7. teja varma

    teja varma Active Member




    good sir, it is better to use http://localhost:9000 beacuse ip address is not same at all time there will be some conflicts at runtime
    it
     


  8. teja varma

    teja varma Active Member


    let me know how you are making network calls weather with retrofit or Okhttp or Background task
     


  9. Govind Arora

    Govind Arora New Member


    hi

    this code returns only companies loaded in tally.

    is there a options to get all companies.

    i found a ref in tally site

    https://help.tallysolutions.com/article/DeveloperReference/faq/8854.html

    but when i try it tally crashed and got msg that memmory execption

    how to use this ref as xml request


    Regards



     
    Last edited: Sep 30, 2019


  10. teja varma

    teja varma Active Member


    just run tally and try this xml request you will get all companies in Data base:
    Code:
    <ENVELOPE>
        <HEADER>
            <VERSION>1</VERSION>
            <TALLYREQUEST>Export</TALLYREQUEST>
            <TYPE>Collection</TYPE>
            <ID>Hostcmpondisk</ID>
        </HEADER>
        <BODY>
            <DESC>
                <STATICVARIABLES>
               <SVEXPORTFORMAT>$$SysName:XML</SVEXPORTFORMAT>
            </STATICVARIABLES>
    <TDL>
    <TDLMESSAGE>
       <COLLECTION Name='Hostcmpondisk'>
       <TYPE>Company On Disk</TYPE>
       <NATIVEMETHOD>Name</NATIVEMETHOD>
       </COLLECTION>
    </TDLMESSAGE>
    </TDL>
    </DESC>
    </BODY>
    </ENVELOPE>
    
     


  11. Sridharan S

    Sridharan S Member


    Great! Can you tell me where one can find Collection Names
    and Types. Is there a list of such ids in Tally site? Thanks
     


  12. teja varma

    teja varma Active Member


    In Tally Developer 9 you will get all the definitions and names
    just download it
     


  13. Govind Arora

    Govind Arora New Member


    thanks

    works great :)


     
    Last edited: Oct 7, 2019


  14. Govind Arora

    Govind Arora New Member


    hi

    can we also get company guid so that in future
    we can get ledger of that company using <SVCURRENTCOMPANY> tag on next command
     


  15. teja varma

    teja varma Active Member


    to get guid:
    $Guid:Company:##SvCurrentCompany
     


  16. Govind Arora

    Govind Arora New Member


    so what will be the XML for it

    actually i have tried collection with xml and got success
    but how to use functions and variables does not get any success.
     


  17. teja varma

    teja varma Active Member


    post you current xml i will modify that one
     


  18. Govind Arora

    Govind Arora New Member


    its same as you have mentioned above
    Code:
    <ENVELOPE>
        <HEADER>
            <VERSION>1</VERSION>
            <TALLYREQUEST>Export</TALLYREQUEST>
            <TYPE>Collection</TYPE>
            <ID>Hostcmpondisk</ID>
        </HEADER>
        <BODY>
            <DESC>
                <STATICVARIABLES>
               <SVEXPORTFORMAT>$$SysName:XML</SVEXPORTFORMAT>
            </STATICVARIABLES>
    <TDL>
    <TDLMESSAGE>
       <COLLECTION Name='Hostcmpondisk'>
       <TYPE>Company On Disk</TYPE>
       <NATIVEMETHOD>Name</NATIVEMETHOD>
       </COLLECTION>
    </TDLMESSAGE>
    </TDL>
    </DESC>
    </BODY>
    </ENVELOPE>

    then to get ledger as you have shown in other thread
    Code:
    <ENVELOPE>
      <HEADER>
      <VERSION>1</VERSION>
      <TALLYREQUEST>Export</TALLYREQUEST>
      <TYPE>Data</TYPE>
      <ID>Hostledgers</ID>
      </HEADER>
      <BODY>
      <DESC>
      <STATICVARIABLES>
      <SVEXPORTFORMAT>$$SysName:XML</SVEXPORTFORMAT>
      </STATICVARIABLES>
      <TDL>
    <TDLMESSAGE>
      <REPORT NAME="Hostledgers">
      <FORMS>Hostledgers</FORMS>
      </REPORT>
      <FORM NAME="Hostledgers">
      <TOPPARTS>Hostledgers</TOPPARTS>
      </FORM>
      <PART NAME="Hostledgers">
      <TOPLINES>Hostledgers</TOPLINES>
      <REPEAT>Hostledgers:Hostledcoll</REPEAT>
      <SCROLLED>Vertical</SCROLLED>
      </PART>
      <LINE NAME="Hostledgers">
      <LEFTFIELDS>ledname</LEFTFIELDS>
      </LINE>
      <FIELD NAME="ledname">
      <SET>$Name</SET>
      </FIELD>
      <COLLECTION NAME="Hostledcoll" >
      <TYPE>Ledgers</TYPE>
      <FILTERS>isreqledger</FILTERS>
      </COLLECTION>
      <SYSTEM TYPE="Formulae" NAME="isreqledger">$Name:Ledger:$Name contains &quot;&quot;</SYSTEM>
    </TDLMESSAGE>
    </TDL>
    </DESC>
    </BODY>
    </ENVELOPE>
    
     


  19. teja varma

    teja varma Active Member


    the problem is that we cant get guid without the company is opened
    so the company should be opened in order to get guid
     


  20. Govind Arora

    Govind Arora New Member


    Suppose the company is opened in tally then
    how do we get the guid in XML
     


  21. teja varma

    teja varma Active Member


    compute method for guid:
    Code:
    <ENVELOPE>
        <HEADER>
            <VERSION>1</VERSION>
            <TALLYREQUEST>Export</TALLYREQUEST>
            <TYPE>Collection</TYPE>
            <ID>Hostcmpondisk</ID>
        </HEADER>
        <BODY>
            <DESC>
                <STATICVARIABLES>
               <SVEXPORTFORMAT>$$SysName:XML</SVEXPORTFORMAT>
            </STATICVARIABLES>
    <TDL>
    <TDLMESSAGE>
       <COLLECTION Name='Hostcmpondisk'>
       <TYPE>Company On Disk</TYPE>
       <NATIVEMETHOD>Name</NATIVEMETHOD>
       <COMPUTE>Guid:$Guid:Company:$Name</COMPUTE>
       </COLLECTION>
    </TDLMESSAGE>
    </TDL>
    </DESC>
    </BODY>
    </ENVELOPE>
    you will only get the guid's of companies that are currently opened in tally
     


  22. Govind Arora

    Govind Arora New Member


    got the company id but
    the initial question was that can we get ledger using company guid:confused: ??
     


  23. teja varma

    teja varma Active Member


    1)you can get ledgers by mentioning company name in the SVCURRENTCOMPANY tag not guid
    or
    2) use guid-> company name resolution process its very simple..

    -> first get the guid of the active company
    ->find the company name from your database with the guid that you got (assuming you stored all the companies and their guid's)
    ->use that company name to get the ledgers and whatever you want..
     


  24. Rajan Mourya

    Rajan Mourya Member


    Thanks for sharing this, but is their any way to get the name of selected company on which user is currently working.
     


  25. Sai Vineeth

    Sai Vineeth Active Member


     
    Last edited: Sep 12, 2023


Share This Page