How to split a message received and send each part to sub process

1
0
-1

Hello,

I have to do a process that will only be done with automatic tasks.

The process should start when a REST call is received. The message received will contain something like

{

"Id": "ORDERID1"

"category": "TMF resource illustration",

"OrderDate": "2018-01-12T09: 37: 40.508Z"

....,

"Orderitem": [

{

"Code": "SERV1"

....

}

{

"Code": "SERV2"

...

}

{

"Code": "SERV2"

...

}

}

The list in the orderItem is not fixed.

My need is that if I receive

- orderItem.code = SERV1, I have to call the subprocess which does the processing linked to SRV1

- orderItem.code = SERV2, I have to call the sub-process which does the processing linked to SRV2

- orderItem.code = SERV3, I have to call the sub-process which does the processing linked to SRV3

Of course I can receive them at the same time as I can receive only one depending on what the customer has purchased.

Of course the list of SERV is variable and is not limited to SERV1, SERV2, SERV3. So i can't make transitions

What do you recommend as an approach and as a way of doing things?

Thank you

1 answer

1
0
-1

Hello,

To do that, you need to create a 'Call activity' task, in the 'Process to call', you just need to user a script that use your 'orderItem.code'.
Then create subprocess that name 'SRV1', 'SRV2', ect

The best way, it's to create a mapping table that contain 'orderItem.code', 'subProjectVersion', 'subProjectName''. Like that, you can have different 'orderItem.code' that can call same subproject.

Regards

Comments

Submitted by mohamed.arrouch... on Thu, 01/23/2020 - 10:35

Hello,

thank you for your proposal. On the other hand, personally I am not very comfortable with the idea of ​​creating sub-processes corresponding to business data (SERV1, SERV2, ...) and elsewhere as I mentioned, the number is variable and can change depending on customer settings. SERV1, SERV2, ... should be seen as functional services (email, voice on the phone, TV on mobile, ....).

I think it's better to explore something like iterator on a list in the message received. If you have examples of implementation, I am interested.

Regards

Submitted by bastien.laurent... on Thu, 01/23/2020 - 11:03

That why i have say :
The best way, it's to create a mapping table that contain 'orderItem.code', 'subProjectVersion', 'subProjectName''. Like that, you can have different 'orderItem.code' that can call same subproject.

So, your subproject can be named like 'email', 'voicePhone', ect. You just need to iterate over your list and map the 'orderItem.code' with the key of your datatable. So, 'SRV1' can call subproject 'email' in version '1.0'.

Submitted by mohamed.arrouch... on Thu, 01/23/2020 - 14:58

Hello,

I will try this.

Thanks for support.

Regards

Submitted by mohamed.arrouch... on Mon, 01/27/2020 - 11:14

Hello,
Being a beginner on Bonitasoft, I need a little more support :) to achieve what you described above.
Is there a document that explains how to do this or do you just have an example that I can rely on to move forward?

cordially

Submitted by bastien.laurent... on Tue, 01/28/2020 - 16:38

That don't concern Bonita. It's just a programmer logic.
create a business data like that:
mappingTable(orderItemCode, subProjectVersion, subProjectName)

Init this table with this value :
orderItemCode = SERV1
subProjectVersion = 1.0
subProjectName = Email

In your Process, create a subProject that name's 'Email' and the version is '1.0'.

Then create a 'Call activity'. This activity need to iterate over your 'orderItem'.
In the 'name' create a script that use the SQL Query 'mappingTable.findByOrderItem' en get only the 'subProjectName'.
Do the same think for the version but return the subProjectVersion instead of 'subProjectname'.

In your test data, create only one order item:

{

"Id": "ORDERID1"

"category": "TMF resource illustration",

"OrderDate": "2018-01-12T09: 37: 40.508Z"

....,

"Orderitem": [

{

"Code": "SERV1"

....

}

Now, run your process. That will call your main process and your subProcess 'Email'.

Regards

Notifications