Object Reference Error - InfoPath Dev
in

InfoPath Dev

Object Reference Error

Last post 07-21-2006 02:44 PM by Matt Faus. 3 replies.
Page 1 of 1 (4 items)
Sort Posts: Previous Next
  • 07-21-2006 12:29 PM

    • JSGSR
    • Not Ranked
    • Joined on 07-21-2006
    • USA
    • Posts 3

    Object Reference Error

    I am trying to programmatically insert a new entry in a sharepoint list when a user clicks a cmd button.

    I am modeling my solution after the how-to regarding deleting a form in a library.

    My XML SEcondary Data Source Looks Like this and is named Add List Item Template:
    <?xml version="1.0" encoding="UTF-8"?>
    <AddListItems>
    <ListName>{0A3CB4D1-CB8D-4AE4-A336-D106517F8D9A}</ListName>
    <Batch OnError="Continue">
    <Method ID="1" Cmd="New">
    <Field Name="Item"></Field>
    <Field Name="Champion"></Field>
    <Field Name="Assigned"></Field>
    <Field Name="Due"></Field>
    <Field Name="Completed"></Field>
    </Method>
    </Batch>
    </AddListItems>

    My Code Looks like this:
    Public Function createFollowUp(ByVal Action As String)

    thisXDocument.GetDOM("Add List Item Template").selectSingleNode("/AddListItems/Batch/Method/Field[@Name = 'item']").text = Action

    Dim webservice As WebServiceAdapter2
    webservice = thisXDocument.DataAdapters.Item(4)
    webservice.Submit()

    End Function

    I get the error:
    System.NullReferenceException
    Object reference not set to an instance of an object.
    at SafetyAudits.SafetyAudits.createFollowUp(String Action)
    at SafetyAudits.SafetyAudits.CTRL647_4_OnClick(DocActionEvent e)
    at Microsoft.Office.Interop.InfoPath.SemiTrust._ButtonEventSink_SinkHelper.OnClick(DocActionEvent pEvent)

    Most of what I have read regarding this error says that I am not referencing the xml properly but I am unable to figure it out...
  • 07-21-2006 01:02 PM In reply to

    Here are some links that are similar.

    http://www.infopathdev.com/forums/topic.asp?TOPIC_ID=2886

    http://www.infopathdev.com/howto/tutorials/default.aspx?i=7bc880f391b84ea9b3b45c6fbecc07c6

    I am not sure it is possible to have the GUID in the CAML template. I thought it needed to be another field since the GUID is identifying the list and not part of the list data.
    I could be wrong but I know the steps in the links work.


  • 07-21-2006 01:51 PM In reply to

    • JSGSR
    • Not Ranked
    • Joined on 07-21-2006
    • USA
    • Posts 3
    I don't think the issue is with how I set up the data sources it appears to be with how i am trying to set the value in the CAML template. What I am trying to do was modeled after this "How-To":

    http://www.infopathdev.com/howto/tutorials/default.aspx?i=1d52979046884d8186c9393a1ea95109

    I want to programmatically assign the value in the CAML like this and that is where the error occurs:

    thisXDocument.GetDOM("Add List Item Template").selectSingleNode("/AddListItems/Batch/Method/Field[@Name = 'item']").text = Action

    Do I have to do something with a namespace to be able to access this CAML I have created?

    Thanks for your time so far. I appreciate your help.
  • 07-21-2006 02:44 PM In reply to

    For some reason the selectSingleNode() statement is not returning a reference to that node. You will have to alter the XPath to correctly select the node. It does sound like there might be a namespace issue here, but if this is just a 2DS that you imported into the form then there shouldn't be a namespace problem. Maybe the 'item' row hasn't been inserted at the time that this code is called?

    You could add a IF block that tests to see if the node is null, and if so, quits.
    Matt Faus / Microsoft InfoPath MVP
    Qdabra® Software / Streamline data gathering to turn process into knowledge
Page 1 of 1 (4 items)
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.