Running business process from client module returns 400 - Bad Request

Hi.

 

I have a business process with a file collection input parameter:

 

 

I am trying to run this process and pass the file collection to it inside a client module of a page, like so:

 

const selectedRowsfirstGrid = request.$context.DataGrid_264vdyg_SelectedRows.__zone_symbol__value;
const selectedRowsSecondGrid = request.$context.DataGrid_c581cyj_SelectedRows.__zone_symbol__value;
 const ids = [...selectedRowsfirstGrid, ...selectedRowsSecondGrid];
 const FilesIdCollection = [];
               
 for(const fileId of ids) {
     FilesIdCollection.push({ FileId: fileId });
 }

 

const handlerChain = sdk.HandlerChainService.instance;
const result = await handlerChain.process({
    type: "crt.RunBusinessProcessRequest",
    processName: "QsProcess_Attach_files_to_the_email",
    processParameters: {
        FilesIdCollection: FilesIdCollection
     },
     $context: request.$context
});

 

I want to mention the fact that the code successfully runs the process if I omit the "processParameters" property, so that's most likely the cause of the error, but I just cannot find what's wrong with it. I looked at the names (code names, not display names), I searched the creatio community a bunch and I just cannot figure it out.

 

Edit: I tried the same code but passed a Guid parameter instead, with a randomly generated Guid and it all works smoothly; the problem seems to be that the collection I am creating is not compatible with the File Collection type from the business process, but how do I make them compatible?

 

Thank you in advance for your help!

Laurentiu

Like 1

Like

2 comments
Best reply

Hello Laurentiu,
Thanks for your question!

As far as i am aware of passing the file from the client side is not supported in Creatio.

However, i tried to implement similar logic to one that you provided. I created a section with attachments and a button which upon clicking executes a business process and passes there a parameter with id's of all selected items in the list page. If the array is empty (i.e no records are selected), the process does not start at all. Then in business process we loop through each account and save the account attachments into an external object (specially created for the process). After the loop, we read all the saved files, attach them to an email, and send the email. Then, i delete the attachments from the special object.

The special object i am referring to is an object that is created in Configurations. I used it as a "buffer" object and it does not contain any useful information.

Here is an example of this implementation: 
list page handler for bp

1

2
 

3

5
611


Hope this helps.
Let me know if you have any question left.

 

Hello Laurentiu,
Thanks for your question!

As far as i am aware of passing the file from the client side is not supported in Creatio.

However, i tried to implement similar logic to one that you provided. I created a section with attachments and a button which upon clicking executes a business process and passes there a parameter with id's of all selected items in the list page. If the array is empty (i.e no records are selected), the process does not start at all. Then in business process we loop through each account and save the account attachments into an external object (specially created for the process). After the loop, we read all the saved files, attach them to an email, and send the email. Then, i delete the attachments from the special object.

The special object i am referring to is an object that is created in Configurations. I used it as a "buffer" object and it does not contain any useful information.

Here is an example of this implementation: 
list page handler for bp

1

2
 

3

5
611


Hope this helps.
Let me know if you have any question left.

 

Hi Yevhenii, thank you so much for your response!

I am currently struggling to understand/replicate how you set up the "Record to store the files in". I created a separate object with an Id and another Guid field. However, when trying to set the value for the field you labeled as "Record to store the files in", I don't see any viable option that resembles your implementation.

 

3

 

Could you please elaborate on the structure of your custom object, and how you came to that value inside the "Record to store the files in" field?

 

Thanks so much again!

Laurentiu

Show all comments