Problems with Repeating Section - InfoPath Dev
in

InfoPath Dev

Problems with Repeating Section

Last post 04-06-2006 05:05 PM by trimba. 6 replies.
Page 1 of 1 (7 items)
Sort Posts: Previous Next
  • 04-06-2006 12:46 AM

    Problems with Repeating Section

    Hi guys,

    Ok, I'm very new with InfoPath and this problem really makes me frustrating already. At this moment on my Main data source, it looks like:

    myFields
    +grpOne
    ++elementOne(rich text)
    +++attributeOne(text)
    +++attributeTwo(boolean)

    I drag grpOne as my Repeating Section, and my objective is when I check attributeTwo, the attributeOne will display username.

    I create OnAfterChange event for attribute two and it looks something like this:
    <InfoPathEventHandler(MatchPath:="/my:myFields/my:grpPointsToNote/my:rtxtPointsToNote/@my:blCompleted", EventType:=InfoPathEventType.OnAfterChange)> _
    Public Sub blCompleted_attr_OnAfterChange(ByVal e As DataDOMEvent)

    ' Write code here to restore the global state.
    If (e.IsUndoRedo) Then
    ' An undo or redo operation has occurred and the DOM is read-only.
    Return
    End If

    ' A field change has occurred and the DOM is writable. Write code here to respond to the changes.
    Dim xmlNode As IXMLDOMNode
    xmlNode = thisXDocument.DOM.selectSingleNode("/my:myFields/my:grpPointsToNote/my:rtxtPointsToNote/@my:tbAssignTo")
    xmlNode.text = System.Environment.UserName
    End Sub
  • 04-06-2006 01:59 AM In reply to

    Re: Problems with Repeating Section

    Oh stupid me ... Where is the question ? :P

    Ok the problem is the event function that I've created above only works for first record on repeating section only. If I insert new item, then I check attributeTwo ... the attributeOne for second,third,... record does not get updated.

    Anyone have any idea how to solve it ?

    Thank you very much ...

    Regards
    Tjen
  • 04-06-2006 06:41 AM In reply to

    • maslov
    • Not Ranked
    • Joined on 04-06-2006
    • Russia
    • Posts 2

    Re: Problems with Repeating Section

    Hello Tjen;

    XPath expression you use always selects the first record in the XML-tree.

    To select the current record, your should use something like this:

    xmlNode = e.Site.selectSingleNode("../@my:tbAssignTo")
    xmlNode.text = System.Environment.UserName

    Regards,
    Maxim
  • 04-06-2006 06:52 AM In reply to

    Re: Problems with Repeating Section

    Hi Trimba,
    So u want to update Attribute1 when u check Attribute2(checkbox) in the same row.

    Use eventObj.Source.selectSingleNode("attributename")instead of
    thisXDocument.DOM.selectSingleNode("/my:myFields/my:grpPointsToNote/my:rtxtPointsToNote/@my:tbAssignTo")

    Using eventObj.Source lets u access the fields in the current row where the event has occured.

    One important point to note is that when u use eventObj.Source, u have to specify only the field name and not the full XPath of the field.
    What Maslov has said above is for C#.What u have to use is eventObj.Source

    Regards,
    Abhishek
  • 04-06-2006 03:45 PM In reply to

    Re: Problems with Repeating Section

    Hi guys,

    Thank you for your fast reply ... My first question will be What's the different between Site and Source ?

    Sorry not to mention it, I create the event using VS2005. So which one will be suitable for me ?

    The other thing, when I try the code. I've got NullReferenceException in

    xmlNode.text = System.Environment.username

    Thank you ...
    Regards
    Tjen
  • 04-06-2006 04:42 PM In reply to

    Re: Problems with Repeating Section

    Thanks guys ... At Last I did it...
    The NullException is because the Field XPath Reference is not correct. And the other thing you need to catch Insert Repeating Section Operation as well. Otherwise, the event function will run twice.

    Anw I'm still wondering what's the difference between Site and Source ?

    Here is my code in case anyone need it


    <InfoPathEventHandler(MatchPath:="/my:myFields/my:grpPointsToNote/my:rtxtPointsToNote/@my:blCompleted", EventType:=InfoPathEventType.OnAfterChange)> _
    Public Sub blCompleted_attr_OnAfterChange(ByVal e As DataDOMEvent)
    ' Write code here to restore the global state.

    If (e.IsUndoRedo) Then
    Return
    End If

    Dim node As IXMLDOMNode
    Try
    If (e.Operation = "Insert") Then
    Else
    node= e.Site.selectSingleNode("../@my:tbAssignTo")
    node.text = System.Environment.UserName
    End If
    Catch ex As Exception
    thisXDocument.UI.Alert("ERROR")
    End Try
    End Sub
  • 04-06-2006 05:05 PM In reply to

    Re: Problems with Repeating Section

    Ok there is another problem ...

    It works fine until I publish it to sharepoint list. The NullException catch and results message box "ERROR" pop up. So, there must be a problem with the XPath of the field.

    This XPath field is annoying yeah ...

    Anyone has experienced the same problem ?

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