Run a script against a field in a repeating section - InfoPath Dev
in

InfoPath Dev

Use our Google Custom Search for best site search results.

Run a script against a field in a repeating section

Last post 07-21-2009 06:21 PM by Jimmy. 6 replies.
Page 1 of 1 (7 items)
Sort Posts: Previous Next
  • 07-20-2009 11:16 AM

    Run a script against a field in a repeating section

    All,

    Still a little new to programming in InfoPath.  I am trying to pull data from a repeating section.  I have done this successfully from a repeating table but when I try to do this from a repeating section, it fails saying:

    The following error occurred:

    Object required: 'oItem.selectSingleNode(...)'
    File:script.vbs
    Line:302

    What do I need to change to get this to work for a repeating section instead of a repeating table?  My code says:

     Dim firstname, lastname, unit
     Dim objXMLNodes, oItem
     Dim Outlook                              ' As New Outlook.Application
     Dim Message                            ' As Outlook.MailItem 

    set objXMLNodes = XDocument.DOM.selectNodes("//my:RecipientInfoRepeat")   '-- RecipientInfoRepeat

    if objXMLNodes.length <= 0 then
         XDocument.UI.Alert("Please Add at leaste One (1) recipient to form before submitting.")
        exit sub
    end if

    If objXMLNodes.length > 0 Then
      For Each oItem In objXMLNodes
           recipientid = oItem.selectSingleNode("my:LogonID").text
           firstname = oItem.selectSingleNode("my:FirstName").text
           lastname = oItem.selectSingleNode("my:LastName").text
           employeetype = oItem.selectSingleNode("my:NonEmployee").text
           location = oItem.selectSingleNode("my:Location").text
           jobfunction = oItem.selectSingleNode("my:JobFunction").text
           emailmessage = emailmessage + classaction + " Recipient --" + recipientid + "--" + lastname + "," & _ + firstname + "--" + employeetype + "--" + location + "--" + jobfunction + cr
    next End If

     

  • 07-20-2009 06:08 PM In reply to

    Re: Run a script against a field in a repeating section

     Repeating Section vs. Repeating Table should make no difference here.  They're just two ways of displaying the data.  Most likely this is a capitalization problem with one of your node names inside the For Each area.  Which line is line 302?

    Jimmy Rishe / Software Developer / Microsoft MVP
    Qdabra Software
  • 07-21-2009 06:25 AM In reply to

    Re: Run a script against a field in a repeating section

    Line 302 is

    recipientid = oItem.selectSingleNode("my:LogonID").text

  • 07-21-2009 06:56 AM In reply to

    Re: Run a script against a field in a repeating section

     Might the field's name be LoginId with a lowercase D or Loginid with all of "ID" in lowercase?  Please double-check the capitalization and if you can't figure it out could you post a screenshot of your data source?

    Jimmy Rishe / Software Developer / Microsoft MVP
    Qdabra Software
  • 07-21-2009 11:13 AM In reply to

    Re: Run a script against a field in a repeating section

    Attached is the screenshot of the Datasource.


  • 07-21-2009 02:29 PM In reply to

    Re: Run a script against a field in a repeating section

    By changing the line:

     set objXMLNodes = XDocument.DOM.selectNodes("//my:RecipientInfoRepeat")   '-- RecipientInfoRepeat

    to

    set objXMLNodes = XDocument.DOM.selectNodes("//my:RecipientInfo")

    The parse now crawls the nodes.  I didn't see this until you made me study the repeating section a little more.

     Thanks for the help!

  • 07-21-2009 06:21 PM In reply to

    Re: Run a script against a field in a repeating section

     Yup, that was the problem.  Glad you figured it out!

    Jimmy Rishe / Software Developer / Microsoft MVP
    Qdabra Software
Page 1 of 1 (7 items)
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.