Skip to main content

Hi,

 

I designed K2 SmartForm where users can enter some data and upload multiple files. I have to send those files to external system. I developed custom Endpoint Assembly and created custom SmartObject with SubmitData method that accepts as parameters fileds from SmartForm. Everything work fine for simple controls like TextBoxes but I also have to send attached files to SubmitData method. I tried to add List<Attachements> parameter to SubmitData method but I could not find a way how to map collection of attachments from SmartForm to that parameter.  I was using list control created base on SmartObject: ID, FileContent to iimplement multiple files upload on the form.

 

Do I have to handle this scenario differently?

 

 

Regards,

  Oleg

I tried to use string instead List. I figured out FileContent field contains XML below. My understendig File Upload controls saves file locally on the disc but I could not finde where. K2 smartforms DesignerFiles or K2 SmartForms RuntimeFiles are alwase empty. Where K2 SmartForm drops uploaded files?

<collection>
<object>
<fields>
<field name='FileName'>
<value>test.pdf</value>
</field>
<field name='FilePath'>
<value>bbdqvesr.pz2 est.pdf</value>
</field>
<field name='FileRequestData'>
<value></value>
</field>
</fields>
</object>
</collection>

I believe the path 'bbdqvesr.pz2' is an Isolated Storage location on the K2 Server:


https://docs.microsoft.com/en-us/dotnet/standard/io/isolated-storage


 


Perhaps this blog contains information of relevance:


https://how2k2.wordpress.com/2017/03/27/getting-an-attachments-isolated-storage-file-path/


Styxol,

 I am not sure exactly sure how your smart object is designed or how the attachments are configured. The way I accomplish this is by creating a table specifically for attachments in SQL. The script looks like this.

 

 

CREATE TABLE PROCESSNAME_ATTACHMENTS

(

ID int IDENTITY(1,1) PRIMARY KEY,

PID int,

Category varchar(20),

Attachment nvarchar(max)

Created datetime,

CreatedBy varchar(40),

)

 

I then create a smartobject off of this.

 

In designer I open the smartobject and change the column type for "Attachments" from memo to file.

 

I then create a list view. When creating the list view under the general tab I uncheck the box that calls the list method when form loads. I then add it to the form and create two rules.

 

The first rule is to create the attachments after the main process has been submitted. I then map the ID from the main process to the PID column in the attachment smartobject. Then I create an unbound rule that calls the list method on the attachments table where PID is equal to the ID of the item opened. I call this rule when the form initializes.

 

 

 

You do not have to configure output mappings.

 

I hope this helps. If you need me to go a little more in depth let me know and I will add some screenshots. I also have another post on this forum that shows a clean easy way to accomplish this. It has fancy popout subviews and all of that jazz.

 

Thanks,

Bryan Peters

 

 

 


 

Thank you for your response. I my case form behavior is very simple once the user will submit a form file attachments will be send to external system and will not be available from K2 SmartForm. I was thinking to create SQL Table to temporarily store files was overkill. My custom SmartObject only can send form data one way to external system. But if it is not possible to directly pass file content as parameter to custom SmartObject I will looks at SQL Table option. Other option is  to read files from  isolated storage.

 

Thanks,

  Oleg 


I stack at how to assign SessionId when user upload a file. I created Table with columns below.

[Id] [int] IDENTITY(1,1) NOT NULL,

[SessionId] [uniqueidentifier] NOT NULL,

[Attachment] [nvarchar](max) NULL,

[Created] [datetime] NOT NULL,

 

I am getting SeesionId from external application via SmartObject. I store SessionId in hidden TextBox from View Initialized event. Next step I want to assign all SmartObject fields when user Upload file attachment.  I am not sure how I can access SessionId. I do not want to plase SessionId in List View. It should not be visible to the user.

 

Regards,

 Oleg


Finally solved the issue. I could set SmartObject fields SessionID and Created from Save button event.

 

Regards,

  Oleg


Reply