MrBlue
Novice

How to Upload a Document to SharePoint and Download it to the K2 Server?

We are trying to upload a document to SharePoint and we also want to download it to the K2 Server. Is there a way to achieve this?.

0 Kudos
Reply
6 Replies
Andrew_Blinco
Apprentice

Re: How to Upload a Document to SharePoint and Download it to the K2 Server?

Hi MrBlue

 

Can you provide some further information:

  • What version of SharePoint do you have?
  • Have you insalled K2 for SharePoint?
  • What User Interface are you using - SmartForms?
  • What do you mean by "download it to the K2 Server"?

 

I suggest you look at the K2 for SharePoint User Guide for more information on how K2 integrates with SharePoint.

 

0 Kudos
Reply
Ray1
Novice

Re: How to Upload a Document to SharePoint and Download it to the K2 Server?

Hi,

 

Here is my scenario. I have sharepoint 2013 online and k2 for sharepoint installed. I am using smartforms and visual studio for k2 as my workflow designer. At a certain step during my workflow, I have few documents residing in sharpoint 2013 document library.

 

I wish to be able to download these documents from my workflow from share point document library to a physical location on K2 server. Then later once I use these documents, I wish to upload these documents from the physical location to the share point document library again from a workflow event.

 

I see "sharepoint 2013 - document events" in toolbox of the visual studio designer for K2 but I don't see any event which upload/download the documents between physical location on computer and sharepoint doc library.

 

0 Kudos
Reply
Latte
Apprentice

Re: How to Upload a Document to SharePoint and Download it to the K2 Server?

Hi, you can use a smartobject event from the SharePoint Library. There's a method to "Save Document to File Loccation" which will allow you download the file to any file system including the K2 server. 

Reply
Ray1
Novice

Re: How to Upload a Document to SharePoint and Download it to the K2 Server?

Thanks Latte, the download part is working now. As you suggested I used the smartobject event "Save Document to File Location" in conjunction with "For each" event to get all the documents downloaded to physical location from a document library.

 

Now, I have another process which merges these downloaded documents and creates a single file. I am trying to upload this single file from a physical location back to the sharepoint document library. I am using the smartobject event "upload document" to upload the file but this doesn't seem to work, maybe I am missing something on how to set the input properties correctly.

 

I am setting the below two input properties for smartobject event "upload document".

 

Document.Content = Get File From Location(New FileName, location with filename) (this is inline function under Files category in function browser)

Document.FileName = Test.docx

 

I am always getting the below error 

The input is not a valid Base-64 string as it contains a non-base 64 character, more than two padding characters, or an illegal character among the padding characters.

 

 

 

 

0 Kudos
Reply
Latte
Apprentice

Re: How to Upload a Document to SharePoint and Download it to the K2 Server?

Hi, 

 

 

This is not so straightforward. 

 

The way I do this is to use the SharePoint 2013 event in K2 Studio, "Upload Document".

Select the source as "Use Content".

The Content will be from the File Inline Function, drag in "Get File from Location", enter the New File Name and The Location with File Name (important you enter the location with the filename like c: est ext.docx). 

 

That should work for you. I've used it several times.

Reply
Ray1
Novice

Re: How to Upload a Document to SharePoint and Download it to the K2 Server?

It worked perfectly. Thank you so much Latte !

0 Kudos
Reply