DataGrid Reactive - delete rows action not working
Question

I realize this is very over-simplified and not an acceptable flow for prod. I'm keeping it as basic as possible on purpose to simplify the troubleshooting. I also realize I can use the debugger for some of this. Thank you for keeping on the point of the problem rather than the end solution I'll be eventually putting into Production! :)

I have a Data Grid and a Delete Rows button with client action to call the RemoveSelectedRows API. That works. Then I have a save button that is using GetChangedLines.RemovedLines and throwing that into a text variable, then deserializing it and populating a list.


After that there is a For Each loop that is using the list variable. It iterates 'each' to send the list.Current.Entity.Id to anther variable (currently_deleting. That one is used by the plain Jane entity CRUD delete action which deletes based on Id.


I also populate an expression on the screen to show the value of currently_deleting so I can see that it is iterating and picking up the row ID correctly. But... the rows don't get deleted  from the table. Any tips as to why?

Yes I mean data deleted from table also. 

For cost category page, if you using it for testing so use action "save_BudgetType_Bl" for testing to confirm action is deleting data from table or not

Hi Jason,

Try adding commit transaction server action after deletezLU_BudgetType action 


Capture122.jpeg

Thanks for your reply. This had no effect. Also, I can the delete data action in other ways (outside of DataGrid) and it works fine without wrapping it in a transaction. Good thought, though!

Hi Jason,

I would suggest to check service center errors after running your action to check if there is any errors or no also you can add Exception Handler to your action and show error message in case any exception.

Most probably this issue happening while deleting record because of relationship between this entity and another entity which means Id column of this table is used as foreign key  into another table with delete rule "Protect".

You can review delete rules if this is the case here:

https://success.outsystems.com/Documentation/11/Developing_an_Application/Use_Data/Data_Modeling/Entity_Relationships/Delete_Rules

There is a referential constraint but no explicit delete rule that I can see. Also, when a referential constraint is violated the exception handler throws the associated exception which is logged.  No exception is getting raised and nothing is logged in this case. It is as if nothing reaches the data action so Outsystems has no exception to raise.

To be sure there's nothing wrong in the data action itself, I properly wrapped it in a server action and called that server action from a simple table with a delete button column. The client action calls the same server action and the row is deleted. It's just not happening with data grid using the REST API.

Can you please share your oml to get more understanding of your scenario and find solution? 

Yes attached. I updated the actions to be closer to production ready. Client Action is in BMTpoc_Admin.oml. The ultimate Server Action is in the _CS.oml. Nothing is happening in the _BL except to bridge the two at this point. Since I can only attach one file per post I'll reply again with the other file. 

BMTpoc_Admin.oml

Here's the CS file. I'm not attaching the BL file because it's nothing but a wrapper for the server action in this one.

BMTpoc_Admin_CS.oml

Hi Jason,

I downloaded two modules but couldn't run them because module "BMTpoc_BT" is not exists and this one which contains database table so if you can share sample of this module with tables in screenshot below this will help me to run and check your application 


Also I noticed that there is a relationship between budget type and cost element with delete rule protect which may also cause an issue while deleting 


I turned off the delete rule and had the same issue. I also tried this on another mock table with no relationships and had the same issue. I can't share the data because there is proprietary data in the database. All of the other rules such as not null throw an exception when the action runs (if applicable.)

If u can share with me structure of tables only this will be enough (at least for table budget) 


BudgetType TEXT
CostElement TEXT
CostElementName TEXT
Id LONG

Hi Jason,

I tried your code and its working fine from my side. I don't have BL layer I called action from CS directly.

I can see you created testing page "CostCategory" which you are using action "Delete_BudgetType_BL". If I am right can you please use action "Save_BudgetTypeChanges_BL" instead and see if it will delete data or not.

I may think about passing some parameters incorrect into BL module.

When you say it's working fine, did you verify that data got deleted and not just removed from the currently displayed grid on the screen?

Also, the Cost Category page, I just threw up a table and added a delete action to make sure there wasn't something going wrong with delete rules. Please ignore it.

Meanwhile I will check out the BL and see if there's some issue there. Thanks!

Yes I mean data deleted from table also. 

For cost category page, if you using it for testing so use action "save_BudgetType_Bl" for testing to confirm action is deleting data from table or not


Thank you for confirming that deletion is occurring for you. I will raise a ticket with our environment support team!

Please forget about Cost Category. It has nothing to do with this. I had just placed a simple table there, populated it with an aggregate, and added a delete button. Since there's no logic to create a list, the save action that I'm using with the Budget Type screen will not work, since there would be no list sent to the server action.

Since you confirmed for me that this works fine in your environment I'm marking this as answered!

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.