Get 'entire' List or Library document with an ID without promoted fields?


  • I have an ID for an item in a Library.  I'd like to (in VSTA) go get a handle on that document and take about 30 fields of information out of it and populate the current MainDataSource for a form I have open.  I have worked with Data Connection in VSTA, getting and receiving, but it would seem I'm 'limited' to those fields that are 'Promoted'.  I'd rather not have to promote those 30 fields just to be able to read them out of the data source.

    Are there some .NET Library classes I can leverage to pass a Library URI to and an ID to return an 'entire' document?  Perhaps it's entire XML?  Without having to use a Data Connection?

    Thank you.
    Thursday, August 20, 2009 2:58 PM

All replies

  • I would recommend you to take a look at XPathNavigator class and its member functions.

    Hope this helps.
    Regards, Paresh
    Thursday, August 20, 2009 3:15 PM
  • This is a good start, thank you.

    After skimming through that, it seems like it's showing me most of everything I've been using to this point, under the assumption that I'm working with a Data Connection that is defined in my InfoPath form, whether Main or a Secondary.

    Isn't it true, however, that the only information I'll have access to through a Data Connection like that are those fields which are selected in it?  Or will I have access to 'all' the fields in the underlying document, even if those values aren't exposed in the Data Connection?

    I ask because I could solve this whole problem by promoting 30 more fields, so I have access to them in my Data Connection, and then I'm done.

    However, I don't really 'want' to promote those 30 fields.  It seems to me I should be able to get 'anything' off that document, even though it's a) not exposed in the Data Connection and/or b) not even 'available' to be exposed in the Data Connection, as the fields aren't promoted.

    Thursday, August 20, 2009 3:24 PM
  • You can get the value of any infopath form field or set value to any any infopath form field programmatically.  Its not necessary to promote the fields.  For instance, there are getValue() and SetValue() methods apart from other useful methods of XPathNavigator class that are helpful in getting and setting form field data.

    Regards, Paresh
    Thursday, August 20, 2009 3:34 PM
  • Ok, let me present this another way.

    I have a secondary data source that points to a Library.  The data source has two fields available in it:  Title and ID.

    I create (successfully) an XPathNavigator to the 'one' item in that data connection using [@ID = n], that works perfect.

    So here I am, with my navigator sitting on one document from the Library, and I can do this:

    xpathnav.SelectSingleNode("@Title", ns).Value;

    ...and I get the value.  However, I can't do this:

    xpathnav.SelectSingleNode("@SomeFieldThatsNotInMyDataSource", ns).Value;

    ...and it blows up on me.  Presumably because my data source doesn't have that field in it.  If that assumption is correct, it then leads me down the path of thinking the only way this will work is if I then make sure 'all' the field information I need to read is in my data source.  The only fields that are available to expose in my data source are those fields which I have previously promoted to my Site Content type (and notice I keep using the work 'Library', this is not a List, for whatever that is worth).

    At the end of all that, I don't 'want' to have to promote some 30-40 extra fields just to get them into my current document.

    So I'm looking for a way to get at 'all' the underlying document data from a document in a Library, when I know the ID, ('without' having to set my form to Full Access, digitally signed, all that as well...I was going down the path of trying to create an XPathDocument from a URL, but it barked at me about the digitally signing thing, so I abandoned that).

    Perhaps you are trying to tell me that, that there's some methods under XPathNavigator that will let me get at values that aren't in my secondary data connection (which my XPathNav is based on).  If you are, I'm just not seeing it, and still having a bit of a disconnect with this whole thing.

    I have this wonderful repeating table hooked to a Library, to allow the user to click a button to select one item.  I'm all the way up to the point where I know the ID, but I can't figure out how to get a handle on that document and get 'all' the data I want out of it at this point, without having to create a Data Connection that has 40 or so fields in it pulling from the same promoted fields in the Library (which I really don't want to promote).

    I guess I'm just thick.  I'll keep at it.
    Thursday, August 20, 2009 4:02 PM
  • Hey I might be onto something.

    What are the following that I'm seeing in the Data Connection wizard:


    Any of those represent the full underlying document?

    If so, what type of object are they?  Is it something where I can create an XML Document or Item directly off something like Copy_Source?

    More digging for me...
    Thursday, August 20, 2009 4:32 PM