Vadim Tabakman

Thanks to the user on Nintex Connect named "Dierk", it's quite simple to create a text file in a document library using Nintex Workflow.

The great thing is, you don't just have to create a flat text file, you can also create other files that are also text based.  Eg.  CSV (comma separated values file that can be opened in Excel).  XML files if you need to store some configuration data.  Even InfoPath forms are XML files, so if you had the spare time and wanted to build up your own InfoPath form xml file, you could do that too.  You could also create HTML files.  You could be making a web service call and get XML back.  You could then use XSLT to transform that into HTML and write the HTML to a file in a document library.

How do we accomplish this?

We use the Web Request action.  A very powerful action which most people don't use because it is a little intimidating.  There are some obvious configuration options like GET and POST.  There are also 2 options for the two versions of SOAP packets you can create to call web services or WCF services.  Then there's the "Other" option.  This is the option we will use in this example because what we want to do is PUT file in a library.

For the URL, we put in the full url including the filename of the document we want to create.

In the body, we insert the text we want as the contents of that file.

That's all there is to it.  It doesn't seem as scary now does it :).

Example

I've created the following:

SharePoint List named "Create Text Files".

SharePoint Library named "Text Files".

The list will contain a choice field where you can pick if you want to create a Text file or a CSV file.  The workflow will then take the title of the item, add the appropriate extension, create a dummy body of the type of file, and then create that file in the library.

As you can see, it's a fairly straight forward workflow:

The Web Request is looks like this:

NOTE: If you create a list and library with the names above and then import this workflow into the list, you should have no problems running this test workflow, excepy you will need to update the credentials used in the Web Request action.  I've configured it to use a Workflow Constant I have.  So either create a constant with that name, or put in the appropriate credentials.

Posted by Vadim Tabakman Tuesday, August 7, 2012 7:46:00 AM Categories: Build Dynamic String Build String Nintex Nintex Workflow Switch Web Request XPath XSLT
Copyright Vadim Tabakman
Rate this Content 4 Votes

Comments

Wednesday, December 19, 2012 8:51:45 AM

re: Nintex Workflow - Creating a Text File in a Document Library

Very interesting and powerful option - just in time as we need to get XML output of metadata from a SP 2007 document library to a file share.

Just to be sure, the Web Request action is in 2010, I presume it's the Call Web Service action in SP / Nintex 2007?

Wednesday, December 19, 2012 9:28:43 AM

re: Nintex Workflow - Creating a Text File in a Document Library

Hi Robin,

there is a Web Request action in NW2007 also, although I haven't tested this functionality out in SP2007.

cheers,

Vadim

Thursday, January 10, 2013 12:08:01 AM
Bhuti

re: Nintex Workflow - Creating a Text File in a Document Library

Thank you Vadim,

This really came handy today. I needed to create an xml everytime an item is created and I used this guidelines instead of creating text, I created an xml and it worked like a charm.

I like that PUT method on the web request action.

Regards

Bhuti

Thursday, April 24, 2014 5:17:00 AM
Lalaounis
Gravatar

re: Nintex Workflow - Creating a Text File in a Document Library

Thanks!!

It really worked!

Thursday, May 15, 2014 12:40:24 PM
Tim
Gravatar

re: Nintex Workflow - Creating a Text File in a Document Library

No matter what credentials I enter in the web request action (site collection admin, farm account, user with permissions, etc.) or how I format them (DOMAIN\username, username@domain, etc.) I always get a 401 Unauthorized error message when running the web request action.  Any ideas on this?

Thursday, May 15, 2014 1:26:15 PM

re: Nintex Workflow - Creating a Text File in a Document Library

Hi Tim,

it could be some type of loopback issue that MS had with SharePoint.  I'm not 100% sure.

http://sharepointconnoisseur.blogspot.com/2011/04/how-to-resolve-401-unauthorized-error.html

cheers,

Vadim

Friday, May 16, 2014 7:17:57 AM
Tim
Gravatar

re: Nintex Workflow - Creating a Text File in a Document Library

Actually resolved this today, or at least found a workaround.  When we tried to call that PUT method on http://sharepoint.company.com/sites/.../textfile.txt we were getting 401 errors.  Replacing that with http://SERVERNAME/sites/.../textfile.txt worked like a charm.  

There's no load-balancing in place, and the loopback check is disabled on all servers, but it might have something to do with the setup of the alternate access mappings?  In any case, it's working now, and is a huge help.

 

Thanks,

Tim

 

Friday, May 16, 2014 7:29:40 AM

re: Nintex Workflow - Creating a Text File in a Document Library

That's awesome. Great find and thanks for sharing your solution.  I'm sure others will hit it also.

cheers,

Vadim

Sunday, June 15, 2014 7:43:08 PM
Mark
Gravatar

re: Nintex Workflow - Creating a Text File in a Document Library

Hi Vadim,

Love your work! I have been trying to implement a Web Request utilising a PUT method. While my request returns data for the record I am trying to update, it does not perform the update. Is there any way to change the Content-type on these requests? I notice if I were to select the POST method , I can stipulate the Content-type for the Request Header, but not so with the PUT method.

Any help would be appreciated.

Cheers,

 

Mark

Wednesday, July 16, 2014 8:06:05 PM
Felix
Gravatar

re: Nintex Workflow - Creating a Text File in a Document Library

Hi Vadim,

Is it possible to write to a file share instead of a sharepoint library? ie. \\servername\folder\test.txt?

 

Thanks.

Felix

 

Thursday, July 17, 2014 2:32:17 AM

re: Nintex Workflow - Creating a Text File in a Document Library

Hi Felix,

at this stage, you would need to write to a document in a document library, then use the Copy to File Share action to copy it to that file share.

cheers,

Vadim

Tuesday, July 22, 2014 7:18:51 AM
Denis
Gravatar

re: Nintex Workflow - Creating a Text File in a Document Library

Hello mr. Vadim,

In first place, thank you very much for your site! It's a great help for me, and very usefull for my work.

I developed a workflow to generate text archive, to make integration with another software. The problem is the special characters, that is printed like symbols (not recognized) to the destination program. My question is: Do you know how can I convert the text to UTF-8, so the special characters can be displayed (and recognized) properly?

Thank you very much for your help,

Regards from Brazil!

Tuesday, July 22, 2014 7:43:15 AM

re: Nintex Workflow - Creating a Text File in a Document Library

Hi Denis,

I'm afraid I don't.  Do you have an example of  a UTF-8 text file you could send me and I could see if there's a way to create one in Nintex Workflow?

cheers,

Vadim

Tuesday, July 22, 2014 8:16:52 AM
Denis
Gravatar

re: Nintex Workflow - Creating a Text File in a Document Library

Hello,

Thank you for the quick help!

We need to eliminate the special characters or,, in best cenario, convert to a format that the characters are displayed correctly.

For exemplo, in my file are printed:

1;4901;1;6NA;SP;GUARATINGUETÁ;6;Consultoria Externa;teste de gravação de log, contendo informações de da requisição salvos em tst;03/04/2014 12:00;15/04/2014 17:00;1;lbrvid1;1;lbrral0;8002

And we expect to have the result:

with UTF-8 codification:


1;4901;1;6NA;SP;GUARATINGUETÁ;6;Consultoria Externa;teste de gravação de log, contendo informações de da requisição salvos em tst;03/04/2014 12:00;15/04/2014 17:00;1;lbrvid1;1;lbrral0;8002

Eliminating special characters:

1;4901;1;6NA;SP;GUARATINGUETA;6;Consultoria Externa;teste de gravacao de log, contendo informacoes de da requisicao salvos em tst;03/04/2014 12:00;15/04/2014 17:00;1;lbrvid1;1;lbrral0;8002

Any of this options can save us!

Thank you very much again,

Denis Silva

 

Tuesday, March 17, 2015 10:39:39 AM
David
Gravatar

re: Nintex Workflow - Creating a Text File in a Document Library

Vadim,

 

Could you update or createa new post that shows this being done with Nintex Forms for Office365?

 

Respectfully, 

David

Tuesday, March 17, 2015 1:34:15 PM

re: Nintex Workflow - Creating a Text File in a Document Library

HI David,

 

great idea.  I'll work on something like that.

cheers,

Vadim

Friday, May 22, 2015 12:50:31 AM
HK
Gravatar

re: Nintex Workflow - Creating a Text File in a Document Library

Hi Vadim, 

First of all, Thanks for the post - it just works. I tried with simple files like TXT, XML, HTML etc. and there is absolutely no issues.

Like Denis - I am now trying to PUT a word DOCX and although the file gets created, the content gets corrupted in the process.

I suppose this could be due to the text variable which holds the streamed document - i.e. encoded in UTF-8

Did you try/get any success with the UTF text he supplied?

Thanks again.

HK

Friday, May 22, 2015 9:46:29 AM

re: Nintex Workflow - Creating a Text File in a Document Library

Hi HK,

this won't work with complex file formats like DOCX, because that is a binary file which won't work with a Web Request PUT.

Instead, look at creating a DOCX template somewhere, and using a Create Item action.

cheers,

Vadim

Tuesday, June 2, 2015 4:35:38 AM
Shyam
Gravatar

re: Nintex Workflow - Creating a Text File in a Document Library

Hi,

I'm trying to generate an HTML file using the Web Request task. I have created a variable which has all the HTML code. But when I try to use the PUT command I get an error "(414) REQUEST URI TOO LONG." It seems the HTML content is too big.

Is there any other alternative how I can achieve this functionlity. I tried using POST but still I'm getting some errors.

Thanks in Advance.

Regards,

Shyam

Tuesday, June 2, 2015 7:41:34 AM

re: Nintex Workflow - Creating a Text File in a Document Library

The Request URI too long, suggests that the URL you are using is too long and not the contents of the html.

Try modifying the url so that the document has a name like a.html and see if that works.  If it does, then it's the URL, definitely.

cheers,

Vadim

Friday, August 21, 2015 2:49:08 AM

re: Nintex Workflow - Creating a Text File in a Document Library

Hi Vadim,

A couple of months I greatly used your method of creating a txt file during a workflow that creates sub-sites.
The text file is filled with an value of the list.

Now I would like to make an workflow that after the value is changed in the list, the text file will be updated or will be delete from the library and created again with the new value.

I have searched the internet, but can only find delete attachments.

Do you have an idea how I could make the delete file?

Cheers Dennis

Friday, August 21, 2015 7:26:44 AM

re: Nintex Workflow - Creating a Text File in a Document Library

Hi Dennis,

a Call Web Service action can call the Lists.asmx web service. Specifically, the UpdateListItems web method.  This web method supports deleting documents in a document library :

https://msdn.microsoft.com/en-us/library/lists.lists.updatelistitems(v=office.12).aspx

cheers,

Vadim

Wednesday, April 6, 2016 9:36:52 AM
David Boa
Gravatar

re: Nintex Workflow - Creating a Text File in a Document Library

Great post.

Is there a way with NINTEX to write the csv file to a file location on the network.

Wednesday, April 6, 2016 8:02:51 PM

re: Nintex Workflow - Creating a Text File in a Document Library

Hi David,

Once you have created the CSV file, put it into a Document Library, then have a workflow run on that document.

In that workflow,use the Copy to File Share action.

cheers,

Vadim

You must sign in to this site to post comments.
Already Registered?
Sign In
Not Yet Registered?
Register

Statistics

  • Entries (279)
  • Comments (1769)

Categories