Cloning while using Master/Detail control - InfoPath Dev

InfoPath Dev

Use our Google Custom Search for best site search results.

Cloning while using Master/Detail control

Last post 01-15-2009 05:43 AM by savita. 0 replies.
Page 1 of 1 (1 items)
Sort Posts: Previous Next
  • 01-15-2009 05:43 AM

    Cloning while using Master/Detail control

    Hi. I am using Infopath 2003 SP2, Access 2003 and prg language is VBScript. I have gone through post for iterating through repeating table.
    The main data source in my form for looks like below:


    I have a master detail control on the form. The form works fine i.e. when a record from master is selected the details of the deals are retrieved, changes made are properly submitted etc.
    I want to clone a deal. My code looks like follows:

    Sub btnClone_OnClick(eventObj)

          dim rootnode, masternode, detailnode, masterrow, detailnodelist, i, tt

          set rootnode = XDocument.DOM.selectSingleNode("/dfs:myFields/dfs:dataFields")
          set masternode = XDocument.DOM.selectSingleNode("/dfs:myFields/dfs:dataFields/d:DealsMaster").cloneNode(true)

          'set all the fields in the masternode
          masternode.selectSingleNode("@deal_id").text() = ""  'this is the primary key of DealsMaster
          masternode.selectSingleNode("@deal_inflow_id").text() = eventObj.Source.selectSingleNode("@deal_inflow_id").value
          masternode.selectSingleNode("@requestor").text() = eventObj.Source.selectSingleNode("@requestor").value
          masternode.selectSingleNode("@deal_start_date").text() = eventObj.Source.selectSingleNode("@deal_start_date").value
          masternode.selectSingleNode("@deal_comments").text() = eventObj.Source.selectSingleNode("@deal_comments").value

          'append the masternode which has new values and get reference to the newly added row
          set masterrow = rootnode.appendChild(masternode)

          'retrieve the first detail node and clone it
          set detailnode = XDocument.DOM.selectSingleNode("/dfs:myFields/dfs:dataFields/d:DealsMaster/d:DealsDetails").cloneNode(false)

          'get all detail nodes
          set detailnodelist = XDocument.DOM.selectNodes("/dfs:myFields/dfs:dataFields/d:DealsMaster/d:DealsDetails")

         'set all the fields in detailnode in a loop
          for i = 0 to detailnodelist.length-1
                 detailnode.selectSingleNode("@detail_id").text() = ""  ''this is the primary key of DealsDetails
                 detailnode.selectSingleNode("@telex_category").text() = detailnodelist(i).selectSingleNode("@telex_category").value
                 detailnode.selectSingleNode("@telex_received_sent").text() = detailnodelist(i).selectSingleNode("@telex_received_sent").value
                 detailnode.selectSingleNode("@telex_from").text() = detailnodelist(i).selectSingleNode("@telex_from").value
                 detailnode.selectSingleNode("@telex_date").text() = detailnodelist(i).selectSingleNode("@telex_date").value
                 detailnode.selectSingleNode("@cloned").text() = "C"

          'submit to database

    End Sub

    My detailnodelist retrieves all the records from the DealsDetails table. I want detail rows only for the current master row.
    Unforunately, I do not know how to loop through the rows which I can see in the detail control. The name of the control is DealsDetails_17.
    I observed something else. If I submit to database after -> set masterrow = rootnode.appendChild(masternode) <-, the first detail record from
    DealsDetails table is added for that masternode.

    Any pointers???? Your help will be highly appreciated.

Page 1 of 1 (1 items)
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.