How to get the URL to an InfoPath content type?

Hi,

I face the following problem:

I created an InfoPath form which is the template for a list on a SharePoint server. This InfoPath form is installed as acontent type. Now, when -from the code of a web service- I want to access the path to the file, thecontentType.DocumentTemplateUrl sometimes returns what I expect (the full URL to the XSN template file), but sometimes returns the path to an almost empty, but definitely useless XML file, like:

http://sharepointserver/MyDocumentLibrary/Forms/template.xml

which is not what I want, of course.

Here's the code I wrote:

Code Snippet

SPList sharePointList = web.GetList (string.Format ("{0}{1}/",

System.Configuration.ConfigurationManager.AppSettings["SPSiteURL"],

listName ) );

// The full path to the XSN file

string xsnPath =default (string );

// Get the document content types for the current list item

if ( sharePointList.ContentTypes !=null && sharePointList.ContentTypes.Count > 0 )

{

// If the list item has a content type, find

// the path to the document template for this list

SPContentType contentType = sharePointList.ContentTypes[0];

if ( contentType !=null )

{

xsnPath =string.Format ("{0}?noredirect=true",

contentType.DocumentTemplateUrl );

}

}

...

So, what I want to know is whether there is a way to get the correct path to the InfoPath template. I am sure there is a mean to accomplish this, as sometimes SharePoint itself returns the correct path, but I would like to know the correct approach.

Thanks a lot,

Zsolt

[3510 byte] By [ZsoltBakos] at [2008-1-10]
# 1

Hi,

maybe you've got more than one Content Type for specified list? Try to remove unnecessary one or use splist.ContentTypes["yourCTname"]

mansa at 2007-10-3 > top of Msdn Tech,SharePoint Products and Technologies,SharePoint - InfoPath Forms Services...
# 2
Hi,

I've already tried those solutions you suggest, but neither worked. That's why I posted it here... Sad

Zsolt

ZsoltBakos at 2007-10-3 > top of Msdn Tech,SharePoint Products and Technologies,SharePoint - InfoPath Forms Services...

SharePoint Products and Technologies

Site Classified