Current SharePoint User - InfoPath Dev
in

InfoPath Dev

Current SharePoint User

Last post 10-19-2006 01:03 AM by hurtlingturtle. 5 replies.
Page 1 of 1 (6 items)
Sort Posts: Previous Next
  • 10-16-2006 08:22 PM

    Current SharePoint User

    Greetings everyone,

    I have an InfoPath 2007 form published to Form Services and all is working great. I am now ready to move on to adding some programatic support to my form so I will be asking a few different questions as I move through what I am trying to accomplish! So, here goes the first.

    To obtain the user currently logged into SharePoint, in the past we had to code a little hack to add an item to a list or library, then read back who it was that posted it. Do we still have to use this approach or does 2007 provide us with any new features?

    Thanks in advance for the help!
  • 10-18-2006 02:33 AM In reply to

    Re: Current SharePoint User

    Use Application.User.UserName in code or through the wizards you can use the userName() function
  • 10-18-2006 03:11 AM In reply to

    Re: Current SharePoint User

    Thank you very much! I did get as far as seeing the Application.User.UserName property. Being new to this I am still struggling to understand a couple of things. Is it safe for me to assume I access the data via an XML DOM? If so, where is it? :)

    I do appreciate the help!

    quote:
    Originally posted by hurtlingturtle

    Use Application.User.UserName in code or through the wizards you can use the userName() function

  • 10-18-2006 03:24 AM In reply to

    Re: Current SharePoint User

    Hi Bob,
    To access the different elements within your InfoPath form you have to use XPaths by making use of the XPathNavigator object. some example code below...
    String xpath = "/ns1:Invoice/ns1:Comments/ns1:CurrentComment";
    XPathNavigator XPN = this.MainDataSource.CreateNavigator().SelectSingleNode(xpath, this.NamespaceManager);

    String currentValue = xpn.Value;
    XPN.SetValue("hello");

    If you don't have any prefixes in your xpath then you don't need the NamespaceManage as a parameter to SelectSingleNode
    hope this helps
    cheers
    Bruce
  • 10-18-2006 10:48 PM In reply to

    Re: Current SharePoint User

    Thank you Bruce, all that worked just great for me! I actually decided to write a simple wrapper class that allowed me to programatically access the XML document throughout all of my code.

    quote:
    Originally posted by hurtlingturtle

    Hi Bob,
    To access the different elements within your InfoPath form you have to use XPaths by making use of the XPathNavigator object. some example code below...
    String xpath = "/ns1:Invoice/ns1:Comments/ns1:CurrentComment";
    XPathNavigator XPN = this.MainDataSource.CreateNavigator().SelectSingleNode(xpath, this.NamespaceManager);

    String currentValue = xpn.Value;
    XPN.SetValue("hello");

    If you don't have any prefixes in your xpath then you don't need the NamespaceManage as a parameter to SelectSingleNode
    hope this helps
    cheers
    Bruce


  • 10-19-2006 01:03 AM In reply to

    Re: Current SharePoint User

    cunning plan. I did the same :-)
Page 1 of 1 (6 items)
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.