Use single collection for two reports?

Discussion in 'Requests' started by arinda, Jan 2, 2020.

         
  1. arinda

    arinda New Member


    I'm getting this xml form response from a web resource into a collection:
    <Departments>

    <Department>
    <Name>M1ock</Name>
    <Teams>
    <Team>
    <TeamName>T1</TeamName>
    <TeamCode>MS1</TeamCode>
    </Team>
    <Team>
    <TeamName>T2</TeamName>
    <TeamCode>MS2</TeamCode>
    </Team>
    </Teams>
    </Department>

    <Department>
    <Name>M1ock2</Name>
    <Teams>
    <Team>
    <TeamName>T1</TeamName>
    <TeamCode>MS1</TeamCode>
    </Team>
    <Team>
    <TeamName>T2</TeamName>
    <TeamCode>MS2</TeamCode>
    </Team>
    </Teams>
    </Department>
    </Departments>

    I want to display the teams on a second report form based on the department selected on the first report. I am linking my web collection on the repeat of the first form. How to use the same for the second report?

    Since the table will have variable length, how to store index without hardcoding or calling the API url multiple times.
     


  2. teja varma

    teja varma Active Member


    you have the main collection
    so create two sub collections ,
    one for names and another for teams
    repeat first collection to show names for selection and store that name in a variable
    then use the name to filter teams collection...….
     


  3. arinda

    arinda New Member


    Im new to tally. Which keywords to look for to achieve this. I used Use to set two different XML object paths but it calls the web request twice which I don't want.
     


  4. teja varma

    teja varma Active Member


    Code:
    [Collection:Xmltestcollection]
        Data Source:File XML:"TestXml.xml"
        XML Object Path:Department:1:Departments
        Client Only:Yes
    
    
    [Collection:Xmltestcollfornames]
        Source Collection:Xmltestcollection
        Source Fetch : Name
        Compute:Name:$Name
    
    [Collection:Xmltestcollforteams]
        Source Collection:Xmltestcollection
         Source Fetch : Teams.*
        Walk:Teams ,Team
        Compute:TeamName:$TeamName
        Compute:TeamCode:$TeamCode
        Compute:Name:$$Owner:$Name
        Filter:onlythatname
    
    [System:Formulae]
        onlythatname:$Name = "M1ock"
    
    [#Menu:GateWayOfTally]
        Add:Key Item:ZendReport:Z:Display:testreport
    
    [Report:testreport]
        Form:testreport
        Title:TestXML
    
    [Form:testreport]
        Part:testpart
        Full Height:Yes
        Full Width:Yes
    
    [Part:testpart]
        Line:testline
        Repeat:testline:Xmltestcollforteams
        Width:100% page
        Scroll:Both
    
    [Line:testline]
        Field:NameField,SimpleField,Short Name Field
        Local:Field:NameField:Set as:$TeamName
        Local:Field:SimpleField:Set as:$TeamCode
        Local:Field:Short Name Field:Set as:$Name
        
    
    ***********************

    Copy the response from the server and paste it in a file ,name it as "TestXml.xml"
    place this xml file in tally directory and load the above TDL code

    ***********************

    go through the working of the code you will understand the concept ……….

    "Xmltestcollection" - main collection that contains response xml

    "Xmltestcollfornames" - sub collection for names

    "Xmltestcollforteams" - sub collection for teams with name filter ( try changing the filter you will understand it)

    there is report (Zend Report) to display the results....

    I think it will give you an idea

    Keep Trying :)
     
    Last edited: Jan 24, 2020


  5. arinda

    arinda New Member


    Thank you. This helped me out a lot
     


  6. arinda

    arinda New Member


    @teja

    Your code still calls the webrequest multiple times. I want to limit the number of calls made to the location and it already returns entire data for first and second report in a single request.
     


  7. teja varma

    teja varma Active Member


    Actually i didn't tested on http request , i tested on xml file instead
    i can't say what the actual problem is...
    i need to analyze your code ,perform unit test to figure out why it making multiple network calls...
     


  8. arinda

    arinda New Member


    You can try by making a mock url using mocky.io with the same mock xml response above and setting the url as source.

    You are not using Xmltestcollfornames collection anywhere. If you use it, Fiddler/Wireshark will show separate requests being called by each of the subcollections.
     


  9. teja varma

    teja varma Active Member


    let me check..

    EDIT:
    Added Source Fetch In SubCollections to Prefetch The Details .. Try Once
     
    Last edited: Jan 24, 2020


  10. nasir

    nasir Member


    Teja bahi kindly chk my request also
     


  11. nasir

    nasir Member


    hi plzzzzzzzzzzzz help me i have udf fields i want create a tanant agrement for every tanant kindly tell me how can i write code for tnaant agreement thanksssssssssssssssssss plzzzzzzzzzzzz
     


Share This Page