Hi everyone, sorry for the beginner question but I'm stuck right now.I am writing an app for sample management. In a form, where I can enter the components to manage, there is the position "in stock / out of stock" via a drop down menu. I decided to use a drop down menu because there may be more choices in the future.
For the drop down I use a record "StatusStock".
On an overview page I list all "in stock" components in a table, all "out of stock" components in another table. For this I use an aggregate with a filter. This all works very well.
Now I would like to add a button in the table to set components directly to e.g. "out of stock" - without using the the form. For this I proceeded as follows.Step 1: Link with icon inserted as "Button" in table and labeled it with "LnkOutOfStockOnClick".Step 2: Double clicked on the link to open the Logic Editor. A new client action "LnkOutOfStockOnClick" was created.Step 3: Dragged "Run Server Action" from the toolbox to the screen and clicked "new server action" in the window.Step 4: Switch to the "logic Application Layer" and click on the new "server action". Changed the name from "Action1" to "GetDataToMoveToOutOfStock". Then double click on the new server action.Step 5: Drag "GetComponent Action" from the data application layer to the logic flow.Step 6: Switch to the "Logic Tab". Added the "ComponentId" input parameter to the "MoveToOutOfStock" action.Step 7: Selected the ewrgenerated "ComponentId" as input parameter of "GetComponent".Step 8: Switch back to the Logic flow "LnkOutOfStockOnClick". As ComponentId I have now selected "GetComponentsInStock.List.Current.Component.Id". Now the record of interest should be available. Now I assigned the new value "Entities.StatusStock.OutOfStock" to the variable "GetComponentsInStock.List.Current.Component.ComponentsStatusStockId" with an assign. At the end I update the tables "Out Of Stock" and "In Stock".Unfortunately nothing happens after compiling when I click on the Button. Where is my thought error.
Thanks for your help.
Michael
Hi Michael Guenther
You are missing an update action. Once you retrieve the detail and change the status to Out of Stock, you should run the update action in order to update the data in the table
Cheers
Hi Michael,
You need to save the record before calling refresh aggregate.
You can use CreateOrUpdateRecord, OR UpdateRecord (built-in actions). Noted: Better to use CreateOrUpdate action.
Hope this helps,
Khuong
Thank you very much for your advice. I have now added the following to the Logic flow.
And I am using "CreateOrUpdate":
But what is the right source for "CreateOrUpdate"?
I added "ComponentId" as Input to "UpdateStockStatus" as I used before for "GetDataToMoveToOutOfStock". But this seems to be wrong?
The source should be the Record. As I see in your pics it should be Component entity.
In GetDataToMoveToOutOfStock action you should have Output Component variable.Then assign value here, assign GetComponent.Record to the output variable.
Then in the assignment, you should update status of GetDataToMoveToOutOfStock.Output (not the Aggregate one).
Then can use GetDataToMoveToOutOfStock.Output as source of CreateOrUpdate action.
Cheers,
It works.
My Mistake: I used the wrong CreateOrUpdate. :-(
For the source I looked at the right "CreateOrUpdate" and used this as template.
Now Outsystems hint me to group the 2 server actions into one. So, what I now did on client side (Get the data, assign the new value, update the data) is better to do it in one server action. Right?
Thanks and best regards.
Yeah, in client action you should call 1 server action (as you can see there will be a warning message if you call multiple server action). You can group all server actions into 1 action then call it in client action.
Best,
Thanks a lot for your help. You put me into the right direction. I grouped them and it works.
Glad to hear that.