HI,
I would like to store the InfoPath file Attachments to Smart Object. I created the smart Object with following Fields ID,FileName, HyperLink (Link to sharePoint document Library Where it store the actual document) So my question is how can i fetch the file name from the InfoPath file attachment control without writing the code behind?
Note: I tried with code behind, but when i open a form it is opening in InfoPath 2007 Client instead of opening in Web browser. I guess code behind has lot of issues to deploy.
I don't have an answer on the filename, but it is possible to open Infopath forms with code behind in a browser, but it does require a Sharepoint administrator to approve the form. Are you integrating with the form in a K2 process and then deploying the K2 process?
The statements and opinions made in my postings are my own, and do not reflect the opinions of SourceCode Technology Holdings, Inc. or its subsidiaries. All information is provided as is with no warranties, express or implied, and grants no rights or licenses.
Thanks for your reply. Yes I am integrating the InfoPath form in K2. I also tried the InfoPath Form Code behind, but when i deploy using K2, Form is opening in InfoPath Client instead of Web browser. Last time i also tried with Deploying the form with Sharepoint Central administration it didnt work. Right now i havent remember what was the error i got at that time. Any way i will try one more time then i will update you the issues which i got.
If i write a code behined in infoPath form, Is it possible to use K2 Classes to update the smart objects fields like fileName and File Content? If yes can you tell me what namespaces i have to Reference and sample code or steps if possible.
1. Deploy the process, which will updated InfoPath Form.
2. Go to the site where the form library resides
a. Click “Site Actions -> View All Site Content”
b. Click on “K2 Blackpearl InfoPath Templates”
i. The new template should be listed here.
ii. Right click on it and select “Copy Shortcut”.
4. Now in MOSS Central Administration.
a. On the menu click “Application Management”
b. Under “InfoPath Form Services”
i. Click “Manage form templates”
ii. Click “Upload form template”
iii. Click “Browse” and paste the shortcut copied.
iv. Click “Open”
v. Click “Upload”
c. Activate the new form to the site collection where the Form Library resides.
5. Back on the form library
a. In “Settings -> Form Library Settings”
b. Under Content Types click “add from existing site templates”. You need to activate content types under the "Advanced Settings" to see this section.
c. Select the new content type. It may be appended with a sequential number e.g. “PurchaseRequest6".
d. The form should now be able to open in InfoPath Form Services. If not, then there is something else wrong with the form that Infopath Forms Services does not like.
Hi VijayKumar
I am not sure if this would apply to your situation but I was able to get the filename after uploading the document to sharepoint without using code.
I noticed that the filename isn't required when uploading to a SharePoint Document Library SmartObject Create method. However, the filename does appear in the document library after uploading even without specifying it (It appears that the SharePoint APIs are extracting the filename from the content header of the binary file when its uploaded).
In addition one of the return values of the SmartObject returns the filename which might be useful if you need the filename later on in the InfoPath form or within the workflow.
Steps to reproduce.
1. Created the SmartObject for the document library using the Smart Objects Services Tester tool.
2. Integrated the SmartObject into the infoPath form selecting the Create method.
3. Added a fileattachment field to the infopath form and a button and configured the button's rules to call the Create method of the Smartobject I integrated passing only the fileattachment field as the value for the required content field. I configured the return property FileLeafRef to populate the fileName field the file was uploaded to sharepoint.
I hope this helps.
Tim
__________________________
Tim Knechtel
Principal - Technologist
K2 Insider
Caprivi Solutions Inc.Toronto, Ontario
I wanted to add one thing to this post because I ran into a small challenge.
I wanted to be able to use the GetList method of the smartobject to show a list of documents that I had uploaded with links to the documents. The challenge I had was that the SharePoint ServiceObject does not give you a straight link but an xml formatted structure….<hyperlink><link>http://www.thelink.com</Link>...etc
To get around this I used some of the built in string methods to parse down the structure and leave the link. For the hyperlink properties add the following in the display and link to data sources:
substring-before(substring-after(LinkToItem_K2_ServiceDefined, "<hyperlink><link>"), "</link>")
-Eric
Here is a link to a little video I did to show it in action:
http://www.k2underground.com/files/folders/videos/entry28307.aspx
Excellent...Glad I could help
Eric,
Can i have the Sample InfoPath Form or project which you showed in the Video? I want to checke the Actions in the Upload button.
I have attached the infopath form that I used in the video to this post.
A couple of notes about the stuff behind the upload button. I created a doclink field and a docname field in order to store the return values from the upload which works good if you only want to upload 1 document in a more realistic scenario you might want to have a smartbox smartobject to store the URLs, file names, and some uniqueID for all the documents related to this instance of the form and then keep the uniqueID in the form somewhere so you can get the list of documents back at a later stage of the process. In my simple case I just added the getlist method of the SharePoint smartobject so that I could retrieve links to all the documents that I uploaded however it will include all documents in that library rather than just the ones related to this instance of the form.
I tried your video tutorial and its great. When i follow your video tutorial, I can able to upload the documents to root site, But i want to upload the documents to document library in a subsite and Every time i upload the document i have to create a Folder and then upload documents into it.
How can i do this?
Thanks
The location of where the documents get uploaded is based upon the smartobject that is being used. You can either create a smartobject for that particular library on the subsite and use that smartobject in the form or you can use the dynamic smartobject capability where you pass URL to a document libary in the input parameters of the Create method. There is more info on this new dynamic capability here: http://www.k2underground.com/blogs/fromthebench/archive/2008/11/21/leverage-existing-smartobjects-to-access-new-sharepoint-sites-created-with-templates-or-site-definitions.aspx
I hope that helps.