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.
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:
I looked around my environment and attempted a few workarounds; however, I do not think this is possible the out-of-the-box K2.
So I did create 2 Columns in the SQL Table...
When insert the text... in the control ....
Upload the same config.txt into the Attachment control...
Later query the Table directly in SQL turn out to have some sort of encoding...
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....
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.
CREATE PROCEDURE [dbo].[StringtoK2File]
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)
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.