Attachment field properties -- is the file location available in the form .NET code?

Good morning,

In the last action of a workflow I’m sending process data over to a different database using an Oracle Connector, called in the .NET code of the form. The workflow has two attachment fields for users to upload documents and I would also like to add those to the other database.

At the moment I’ve done a similar connection to our WorkflowGen database and queried for the process instance and field names to get the file location. This works, but since the form itself has a nice link for users to download the attachments, I was wondering if there’s already an attribute available on the Attachment field with the attachment file location? For example, a text field has EXAMPLE_TEXT_FIELD.Text, is there something like EXAMPLE_ATTACH.Path ? If it’s already there obviously I’d rather use that than an unnecessary database connection.

Thanks very much!
Alison

Hi Alison,

The attachments use the FileUpload class in C#:

For security reasons, there is no way to retrieve the file path from the control.

What is your purpose in getting the file path in code behind?

Regards,
Eddy.

Okay, thanks, that’s good to know.

The form is an approval process and approved requests go into our own CRM. The documentation (currently uploaded to the form) has always been stored in our CRM and does need to be referenced later, so I’d like to send it to our CRM and have it all where users expect it. I do have that working, but wanted to check if I was needlessly doing an extra call to our WFG database to look for the file location.

I may check into the web API later but my method seems fine for now.

Thanks again!

Hi @Alison.Stewart ,

Usually for these cases I would create a custom Assembly application that would be called after the form is submitted.

The method in the assembly would have a WorkflowFile object parameter that would be expecting a file from the workflow as an IN parameter.

In the method, you can retrieve the content of that document as a byte array using the WorkflowFile’s Content property and then call the CRM’s API to send that document :

Example of an Assembly method usage with a file parameter:

1- Create a C# class library
2- Create the method that will retrieve the file and send it to the CRM via API

public string SendToCRM(WorkflowFile file){
     CRM.API.SendFile(new MemoryStream(file.Content));
  }

3- Build the solution and deploy the Assembly(dll file) in the wfgen\bin folder
4- Create a new custom application of type assembly that references the newly created dll file.
5- Create a new action in the Workflow with the new custom application and map the file to be sent as an IN parameter.

This is a lengthier approach than using the .NET code in the form, but definitely more clean and maintainable.

Regards,
Eddy.