
In my previous two articles, I covered how to insert and update data from client-side code in Creatio. This last article in this series will cover how to do deletes from client-side code as well.
Similar to how UpdateQuery worked, we’ll provide a filter (just like with EntitySchemaQuery) that indicates the record, or records, to delete. We can delete a single record, or multiple, that all depends on the filters we provide. For the scenario, we’ll assume we have an object UsrWidget that is a 1:many detail on the account. We’ll delete all of the widgets for the current account. Let’s look at the code:
var deleteQuery = Ext.create("Terrasoft.DeleteQuery", { rootSchemaName: "UsrWidget" }); deleteQuery.filters.add( deleteQuery.createColumnFilterWithParameter(Terrasoft.ComparisonType.EQUAL, "UsrAccount", this.get("Id")) ); deleteQuery.execute();
Just as with InsertQuery & UpdateQuery, when we execute the delete we can add a callback to occur after the delete is complete, like this:
deleteQuery.execute(function() { // do something here }, this);
or this:
deleteQuery.execute(this.myCallbackFunction, this);
As always, you should always consider where the best place is to perform an operation like this. Keep in mind, doing this from the page code means that the logic won’t happen for imports or things that might trigger from other server events since it only exists on the page.
Subscribe To Our Newsletter
Join our mailing list to receive the latest Infor CRM (Saleslogix) and Creatio (bpm'online) news and product updates!
You have Successfully Subscribed!