on 09-11-2015 4:10 PM
Dear experts,
how many choices do we have in order to delete an instance of a customer BO?
e.g.
businessobject MyCustomBO {
[AlternativeKey ] element ID : ID;
element e1 : aType;
...
}
Right now I only know 1 way which is using a stackpanel in OWL --> eventhandler --> list --> remove row --> bind to data list
In the documentation, there is a short paragraph: but it does not delete the BO in the root level but the node beneath it.
@Fred K has suggest another workaround in the comment of the post but it does not work for me.
Much appreciate your help.
Best regards
Linh
7.2.4.19 Delete Instance (Business Logic)
Syntax <this | NodeInstanceVar>.Delete();
Description The Delete operation, which uses the inverse semantics of the Create operation, can only be called in the
instance-based variant and must be applied to business object nodes. The reason is that the instance to
be deleted must be identified by the preceding member path expression. The Delete operation can also be
applied to collections of business object nodes.
Example foreach (var BO in TestBO.QueryByElements.Execute()) {
if (BO.Name == "delete") {
BO.Delete();
}
}
Deletion of a collection of nodes:
TestBO.QueryByElements.Execute().Delete()
Hi Linh,
Have you tried with BOOperation READ?
It actually works for me. And I think that is a good way.
1. Bind Root with Custom BO
2. Bind DataList with Custom Query
3. Bind a data field under Datalist with the NodeID from Custom Query.
4. Create an event handler.
5. Add BOOperation READ and read Custom BO using NodeID
6. Add delete BOAction with instance binding to ROOT.
Dont forget to check "Save After Execution".
The delete BOAction should only include (this.Delete() ).
I recommend to recreate the UIs and test.
Good luck,
Fred
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Fred,
I tried that too. I think there must be something with other script files which hinders the this.Delete() to be executed.
I implemented some script codes in beforeSave and afterModify, which checks "this" - current instance and do some caculation.
I set a condition (e.g. afterModify) if (this.IsSet()) { do calculation...}
But it still doesnt work.
I'm not sure if after this.Delete(), this.IsSet() will return false or not.
Do you think this could be a problem? And how to solve it?
Many many thanks
Best
Linh
Hi Linh,
What if this.IsSet() retuns false, what happen?
But that should not be a problem.
You don't need to use this.IsSet(), AfterModify will run before the Delete.
Our issue is we cannot delete the selected row using List->Remove.
Because the data list is bound to the custom Query and custom Query doesn't not allow that.
The workaround is to get the NodeID of the selected row, read the instance of the selected row using the NodeID and delete it.
First, I bound the Root with the Custom BO because I am going to use BOOperation on that custom BO.
Second, the data list was bound with the custom query.
Third, I created a new data field under Data list and bound with NodeID from the custom Query.
So, whenever I select a row, I can get the NodeID of the instance.
Fourth, I can get the instance if I have the NodeID. Because NodeID is like a unique ID.
I used BOOperation READ to read the custom BO with the NodeID. Then, I got the instance.
Fifth, I added a BO Action Delete (this.Delete) after the BOOperation READ.
As a result, the instance is deleted.
Best Regards
Fred
Hi Horst,
sometimes it is not possible to use operation list --> RemoveRow in the UI that's why I need another way to delete the BO.
ABSL code is to create an action and in the UI use BOAction to trigger this code.
ABSL in standard docu only has those description I posted above.
Best regards
Linh
I know this thread is 4 years old now, but I stumbled across it after hitting the same problem where the delete action gets called in an infinite loop. It turns out naming the action Action-Delete.absl (as per latest screenshot) results in the call to this.Delete() getting rerouted to that action - so the action ends up just calling itself over and over again. After changing the name to something else like Action-DeleteInstance.absl it then calls the normal Delete() function which removes the instance, and no more infinite loop!
BR,
Simon
User | Count |
---|---|
86 | |
10 | |
10 | |
9 | |
7 | |
7 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.