form library title

G

Greg Belenky

How I can get document form library name in SharePoint to display it in
information text box on form?
 
G

Greg Belenky

How I can get document form library name in SharePoint to display it in
information text box on form?

If someone interested - I've just found solution for subject question:

1. Add to the Infopath form field to store library title, name it "Title"
for example
2. Define managed OnLoad event handler
3. Make web reference for Sharepoint's Lists web service:
http://<sharepoint>/sites/<site>/_vti_bin/Lists.asmx?wsdl
4. OnLoad handler will look like:
[InfoPathEventHandler(EventType=InfoPathEventType.OnLoad)]
public void OnLoad(DocReturnEvent e)
{
try
{
Lists ws = new Lists();
ws.Credentials = CredentialCache.DefaultCredentials;
XmlNode sps = ws.GetListCollection();

XmlNamespaceManager mngr = new XmlNamespaceManager(
sps.OwnerDocument.NameTable );
mngr.AddNamespace( "def",
"http://schemas.microsoft.com/sharepoint/soap/" );

string solutionUri =
HttpUtility.UrlDecode(thisXDocument.Solution.URI.ToString());
string uri = new Uri(HttpUtility.UrlDecode(solutionUri),
true).PathAndQuery;

XmlNode lib = sps.SelectSingleNode( "//def:List[@DocTemplateUrl='" + uri
+ "']/@Title", mngr );
IXMLDOMNode num = thisXDocument.DOM.selectSingleNode( "//my:Title" );
if ( lib != null ) num.nodeTypedValue = lib.InnerText;
}
catch
{
thisXDocument.UI.Alert( "Can't get library title");
}
}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top