Create action with multiple parameters not supported yet. Will process the first parameter only

If you have questions or if you want to share your opinion about Aware IM post your message on this forum
Post Reply
weblike
Posts: 1165
Joined: Sun Dec 02, 2012 12:00 pm
Location: Europe

Create action with multiple parameters not supported yet. Will process the first parameter only

Post by weblike »

Hello,

Please test this simple BSV attached which contains 2 Business Objects: Orders, Invoices
createActionBSV.zip
(39.38 KiB) Downloaded 473 times
How to test:
1. Create Orders mannualy
2. From menu Orders-> select multiple orders and click the "Create Invoices" button.
3. Even you select 5 orders it will create only 1 Invoice.

Description of bsv:
Orders are created manually and Invoices records are created with this simple process.

Code: Select all

CREATE Invoices WITH Invoices.customer=Orders.customer,Invoices.number=Orders.number
In query qryOrders there is a button which is applicable to multiple items and fires the process for creating Invoices records.
2020-11-03_08-47-36.png
2020-11-03_08-47-36.png (24.32 KiB) Viewed 14091 times

My question is it normal that it creates only one record despite the fact I select multiple records?
In log view I can see this message:
2020-11-03_08-50-00.png
2020-11-03_08-50-00.png (16.64 KiB) Viewed 14091 times

Searching the forum I can find only 1 post with this subject which happened many many years ago.

https://www.awareim.com/forum/viewtopic ... +yet#p2891
Thx,
George
________________________________
Developer Edition
AwareIM: v8.5, build 2824
OS: Windows Server 2012
DB: MySql 5.6.42
ACDC
Posts: 1138
Joined: Sat Jun 30, 2007 5:03 pm
Location: California, USA

Re: Create action with multiple parameters not supported yet. Will process the first parameter only

Post by ACDC »

I think this option is meant for basic processes like a Delete object with some extended requirements

I havent looked at the BSV , but why not create a process that simply:
FIND Orders WHERE....
and then CREATE Invoice FOR EACH Order WITH Invoice.customer=Order.customer,Invoice.number=Order.number
weblike
Posts: 1165
Joined: Sun Dec 02, 2012 12:00 pm
Location: Europe

Re: Create action with multiple parameters not supported yet. Will process the first parameter only

Post by weblike »

Thank you for your reply.
I could do that, but in the log you can see that all the selected records are included in execution.
2020-11-03_10-27-33.png
2020-11-03_10-27-33.png (2.97 KiB) Viewed 14083 times
& in the post form 2006...there is a comment "Thanks a lot to Vladimir for solving this problem with build 920 !".
If it was possible then, I'm convinced it is possible even now :)

Cheers.
Thx,
George
________________________________
Developer Edition
AwareIM: v8.5, build 2824
OS: Windows Server 2012
DB: MySql 5.6.42
nhofkes
Posts: 94
Joined: Mon Sep 07, 2020 6:03 am
Location: Netherlands

Re: Create action with multiple parameters not supported yet. Will process the first parameter only

Post by nhofkes »

You should change your process rule to:

Code: Select all

CREATE Invoices FOR EACH Orders WITH Invoices.customer=Orders.customer,Invoices.number=Orders.number
I added the words "FOR EACH Orders" and then it works fine - I tested this with your sample application.
You can call your process createInvoices with multiple orders, but then you should invoke the command CREATE for each Invoice separately by using FOR EACH.

By the way, I noticed that you named your objects "Invoices" and "Orders". It is good practice to name them in singular form, i.e. "Invoice" and "Order". Then the process rule would be "CREATE Invoice FOR EACH Order..." which is easier to read.
Niels
(V9.0 build 3241 - MariaDB - Windows)
BLOMASKY
Posts: 1470
Joined: Wed Sep 30, 2015 10:08 pm
Location: Ocala FL

Re: Create action with multiple parameters not supported yet. Will process the first parameter only

Post by BLOMASKY »

A process generally ONLY works with one instance of an item at a time. (Yes there are exceptions. i.e.
FIND BO where BO.x =1
BO.y = 2
Will update all copies of BO that were found.

However, if you wrote
FIND BO where BO.x = 1
Create Invoices where Invoices.field1 = BO
Will ONLY create 1 invoice record

You can either add the FOR EACH in the create
OR
Call a sub process with BO as an input field.

Now to confuse you
FIND BO1 .... (2 Matches)
FIND BO2 .... (3 Matches)
Process2 with BO1 and BO2 as inputs will be called 6 times with each possible combination.

Bruce
tford
Posts: 4238
Joined: Sat Mar 10, 2007 6:44 pm

Re: Create action with multiple parameters not supported yet. Will process the first parameter only

Post by tford »

Now to confuse you
FIND BO1 .... (2 Matches)
FIND BO2 .... (3 Matches)
Process2 with BO1 and BO2 as inputs will be called 6 times with each possible combination.
I didn't know that, Bruce!
Tom - V8.8 build 3137 - MySql / PostGres
nhofkes
Posts: 94
Joined: Mon Sep 07, 2020 6:03 am
Location: Netherlands

Re: Create action with multiple parameters not supported yet. Will process the first parameter only

Post by nhofkes »

Bruce, I also didn't know that, thanks for the addition.

Now just to be sure, when you say "a process generally ONLY works with one instance of an item at a time", do you mean to say that what I wrote is not correct or do I understand it incorrectly? Because I tested it with the bsv sent by weblike and it seemed to work (with my adjustment). To summarize, weblike created a process that is called by a panel operation in the query and ticked 'Applicable to multiple items'. This results in a call to the process where multiple objects are passed as input, as can be seen in the log. Then in the process itself, with the additional wording FOR EACH, the CREATE command is invoked for all of those objects that are passed as input to the process.

Perhaps what you mean (and I agree) is that this cannot be extended to any process generally - i.e. because in this specific example the process only consists of one action 'CREATE' we can use FOR EACH to handle each object, but if the process would consist of several steps we cannot assume that all of those steps are executed separately for each object. In practice this can be resolved by working with subprocesses (because the subprocess is called for each object separately), but I have to say that it is at times like this that I miss the more flexible looping constructs that are available in traditional programming languages.
Niels
(V9.0 build 3241 - MariaDB - Windows)
tford
Posts: 4238
Joined: Sat Mar 10, 2007 6:44 pm

Re: Create action with multiple parameters not supported yet. Will process the first parameter only

Post by tford »

Code: Select all

but I have to say that it is at times like this that I miss the more flexible looping constructs that are available in traditional programming languages.
Calling sub-processes works in basically the same way. I carefully name my processes when they have subs so at a glance I know the relationship / role of each piece.

Process_Step_0
Process_Step_1
Process_Step_2
Tom - V8.8 build 3137 - MySql / PostGres
aware_support
Posts: 7523
Joined: Sun Apr 24, 2005 12:36 am
Contact:

Re: Create action with multiple parameters not supported yet. Will process the first parameter only

Post by aware_support »

When you set "Applicable to multiple items" for a process that has some input (Orders in this case - should be Order, Niels is right), then all Orders that the user selects as input are written into the Context of the process. So all actions in the process have to deal with multiple instances of the input in Context. The safest way to handle this situation is to define a sub-process with the same input as the parent process (Orders) and just call this sub-process inside the parent process.

The sub-process will then be called once for every instance of Orders in the Context, so the sub-process will deal with ONE instance only in the Context. So the sub-process can just CREATE an Invoice without using FOR EACH
Aware IM Support Team
weblike
Posts: 1165
Joined: Sun Dec 02, 2012 12:00 pm
Location: Europe

Re: Create action with multiple parameters not supported yet. Will process the first parameter only

Post by weblike »

aware_support wrote: Tue Nov 03, 2020 10:31 pm When you set "Applicable to multiple items" for a process that has some input (Orders in this case - should be Order, Niels is right), then all Orders that the user selects as input are written into the Context of the process. So all actions in the process have to deal with multiple instances of the input in Context. The safest way to handle this situation is to define a sub-process with the same input as the parent process (Orders) and just call this sub-process inside the parent process.

The sub-process will then be called once for every instance of Orders in the Context, so the sub-process will deal with ONE instance only in the Context. So the sub-process can just CREATE an Invoice without using FOR EACH
Thank you for the reply.
I will test
Thx,
George
________________________________
Developer Edition
AwareIM: v8.5, build 2824
OS: Windows Server 2012
DB: MySql 5.6.42
Post Reply