Skip to main content
Nintex Community Menu Bar

I need to generate a Text File from a K2 Form.... similar to the PDF Control but as Text File...

  • December 5, 2018
  • 4 replies
  • 201 views
  • Translate

Forum|alt.badge.img+10

Guys, currently there is a need to create a Text File from the input entered by the user in a form. this should generate a Text File with the appropiate information, and like to store and email as attachment.

 

I wonder if somebody have some suggestions on how to achieve this... 

 

Best Regards Dino.

Did this topic help you find an answer to your question?

4 replies

Forum|alt.badge.img+5
  • 25 replies
  • December 5, 2018

Hey Dino,


 


I ran quick search to see if anyone else has attempted this. I was able to find this link to another community post where the customer wanted to read and write to a text file:


 


https://community.k2.com/t5/General/Read-and-Write-to-a-TEXT-file-From-SmartForm/td-p/102100


 


I looked around my environment and attempted a few workarounds; however, I do not think this is possible the  out-of-the-box K2. 

Translate

Forum|alt.badge.img+10
  • Author
  • 145 replies
  • December 5, 2018

So I did create 2 Columns in the SQL Table... 

 

some_text varchar(max)

some_attachment nvarchar(max)

 

When insert the text... in the control ....

!

Some_TEXT

!

 

Upload the same config.txt into the Attachment control...

Later query the Table directly in SQL turn out to have some sort of encoding...

<file><name>config.txt</name><content>IQ0KaG9zdG5hbWUgVEVTVA0KRE5TIDEwLjIzNi4wLjYxDQoh</content></file>

That makes me wonder if somehow can figure it out the encoding and compose the data to insert directly without using the File Control from K2 perhaps might be able to compose the string to be inserted and expet the K2 List to read it later....

 

 

Translate

Forum|alt.badge.img+10
  • Nintex Employee
  • 62 replies
  • December 6, 2018

Hi Dino


 


The File Attachment control saves the file content as a Base64 encoded string.


 


You should be able to insert text as File Attachment control usable content using a Stored Procedure.


 


Something like


CREATE PROCEDURE [dbo].[StringtoK2File]
@Filename nvarchar(50),
@String nvarchar(MAX)
AS
BEGIN

DECLARE @K2File nvarchar(MAX), @Encoded nvarchar(max)

SET @Encoded = (SELECT CAST(@String as varbinary(max)) FOR XML PATH(''), BINARY BASE64)

SET @K2File = (SELECT '<file><name>' + @Filename + '</name><content>'+ @Encoded + '</content></file>')

INSERT INTO [dbo].[MyFiles] ([Text], [MyK2File],) VALUES (@String,@K2File)

END

One thing to remember though is when generating a SMO from the dbo.myfiles table, is that the MyK2File property will default to type Memo. You will need to change the property to a type File so you can use the content as a file.


 

Translate

Forum|alt.badge.img+6
  • Rookie
  • 43 replies
  • October 31, 2023
ThinusC wrote:

Hi Dino

 

 

 

 

The File Attachment control saves the file content as a Base64 encoded string.

 

 

 

 

 

You should be able to insert text as File Attachment control usable content using a Stored Procedure.

 

 

 

 

 

Something like

 

 

CREATE PROCEDURE [dbo].[StringtoK2File]       @Filename  nvarchar(50),       @String  nvarchar(MAX)ASBEGINDECLARE @K2File nvarchar(MAX), @Encoded nvarchar(max)SET @Encoded = (SELECT CAST(@String as varbinary(max)) FOR XML PATH(''), BINARY BASE64)SET @K2File = (SELECT  '<file><name>' + @Filename + '</name><content>'+ @Encoded + '</content></file>')INSERT INTO [dbo].[MyFiles] ([Text], [MyK2File],) VALUES (@String,@K2File) END

 

 

One thing to remember though is when generating a SMO from the dbo.myfiles table, is that the MyK2File property will default to type Memo. You will need to change the property to a type File so you can use the content as a file.

 

 

 

 

So where does the file reside in this scenario?

Translate

Reply


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie Settings