Deleting Records from Client-Side Code using DeleteQuery in Creatio (formerly bpm’online)

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.

Want content like this delivered to your inbox? Sign up for our newsletter!
ABOUT THE AUTHOR

Ryan Farley

Ryan Farley is the Director of Development for Customer FX and creator of slxdeveloper.com. He's been blogging regularly about SalesLogix, now Infor CRM, since 2001 and believes in sharing with the community. His new passion for CRM is Creatio, formerly bpm'online. He loves C#, Javascript, web development, open source, and Linux. He also loves his hobby as an amateur filmmaker.

Submit a Comment

Your email address will not be published. Required fields are marked *