Obtain Form Library/List Name - InfoPath Dev
in

InfoPath Dev

Obtain Form Library/List Name

Last post 12-12-2008 02:47 AM by Jimmy. 2 replies.
Page 1 of 1 (3 items)
Sort Posts: Previous Next
  • 12-11-2008 01:35 PM

    Obtain Form Library/List Name

    I need to be able to get the path i.e. \\moss\MyFormLibrary that the form was started in - I actually only need the Library name...like MyFormLibrary...is this possible during the OnLoad event using script? It's in the manifest like:

     

     <xsf:extensions>
      <xsf:extension name="SolutionDefinitionExtensions">
       <xsf2:solutionDefinition runtimeCompatibility="client" allowClientOnlyCode="no">
        <xsf2:dataConnections></xsf2:dataConnections>
        <xsf2:offline openIfQueryFails="no" cacheQueries="no"></xsf2:offline>
        <xsf2:viewsExtension>
         <xsf2:viewExtension ref="CME Provider Document Properties - Server" designMode="normal" clientOnly="no"></xsf2:viewExtension>
        </xsf2:viewsExtension>
        <xsf2:sendByMail disableEmailForms="yes"></xsf2:sendByMail>
        <xsf2:solutionPropertiesExtension branch="contentType">
         <xsf2:contentType sharepointContentTypeId="0x0101006B16354B4D69DF47A96A5074B9679FD000AD39342B20E9484FA2399697AD3F0055" path="http://scma/cmeacc/Template">
         </xsf2:contentType>
        </xsf2:solutionPropertiesExtension>
       </xsf2:solutionDefinition>
      </xsf:extension>
     </xsf:extensions>

    which is actually part of a DIP of a ContetntType in the "Template" library. I need "Template" from code...

    Filed under:
  • 12-11-2008 08:18 PM In reply to

    Re: Obtain Form Library/List Name

    Hi,

    Use the following code lines to get the library name. Note: This code works if the url is in the form of //" target=_blank>http://<servername>/<libraryname>/.... Ex: http://server3/test1/Forms/template.xsn. You can get the value ‘test1' by using the below c# code lines.

    string url = thisXDocument.Solution.URI;

     url = ((url.Remove(0, url.Substring(0, url.IndexOf("//") + 2).Length)).Remove(0, url.Substring(0, url.IndexOf("/") + 3).Length)).Substring(0, url.IndexOf("/") - 1);  

    Swathip
    www.ggktech.com
  • 12-12-2008 02:47 AM In reply to

    Re: Obtain Form Library/List Name

    I think this would be a bit tidier:

    string url = thisXDocument.Solution.URI;
    string[] parts = url.Split(new char[] { '/' }, StringSplitOptions.RemoveEmptyEntries);
    string listName= null;
    if (parts.Length >= 3)
    {
         listName = parts[2];
    }

    Jimmy Rishe / Software Developer / Microsoft MVP
    Qdabra Software
Page 1 of 1 (3 items)
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.