Question

Blob to variable in Script Task

I have this Script Task code for receiving file name from opportunity files record:

string RecordIdParam = Get("RecordID");

var result = "";

// Creating a query to the "OpportunityFile" schema, adding the "Name" column to the query.

var esqResult = new EntitySchemaQuery(UserConnection.EntitySchemaManager, "OpportunityFile");

var colName = esqResult.AddColumn("Name");

// Executing query to the database and receiving the object with the specified identifier.

var entity = esqResult.GetEntity(UserConnection, new Guid(RecordIdParam));

// Receiving value of the object column.

result += entity.GetColumnValue(colName.Name).ToString();

Set("fileName", result);

return true; 

 

I need to receive, in addition to the file name, the content of the blob to a binary variable for further use.

Can you please tell me what are the lines of code for this ?

Like 0

Like

4 comments

Hello Oren!



If you want to process the data on server side, than you can check how to read data column in FileLoader class. 

But I don`t recommend to work with files in such way. Much more convenient way is described here: https://community.bpmonline.com/questions/where-find-attachments-activity



Idea is not to process and convert the data into some object on server side, but read its value and insert in database where it is needed.



Perhaps, if you will check how system works with files on server side in oob functionality it will be helpful. Just search schemas in configuration with such filters http://prntscr.com/nocypn 

Alex_Tim,

Thanks Alex for your answer.

It won't work for me because I need the file outside the DB, for example to deliver it to an FTP server.

SO do you know how to save it as a Binary variable ?

Or if you can tell me where to find this "FileLoader class"?

Oren Diga,

 

You can simply find it in configuration by entering it`s name.

Basically if you will search by such filters http://prntscr.com/nocypn  you will find many examples. 



Class that I have mentioned earlier ("FileLoader") lays in "FileLoader" schema in "Base" package. It is used for downloading the files. If I were you, I would give some thought to use it in my service or business process.



Regards,

Alex 

Thanks Alex!

This is very helpful.

Show all comments