
There are many occasions where you might need to know when a row has been added, edited, or deleted in a detail in Creatio from the page where the detail has been added. An example of this is in the Order area, where you can add/edit/delete rows in the products detail and the total of all the products is displayed as rows get added, updated, or deleted. There are a few different ways you can accomplish this, such as sending server messages from a process that has add/edit/delete signal start elements that send messages back to the page, such as how this article outlines. However, you can also do this as a completely client-side solution as well and wire up a method on the page to be called when add/edit/delete events occur in the detail. Think of this as wiring up a change event for a detail.
Let’s say you have a detail on a page called AccountWidgets. You want to know when add/edit/delete events occur in this detail on the Account page where it has been added. First of all, with the detail added to the page, you’ll see it like this in the page’s detail section (this is what you’ll see in the page code after added the detail normally in the section or page wizard):
details: /**SCHEMA_DETAILS*/{ "AccountWidgets7f8633dc": { "schemaName": "AccountAddressDetailV2", "entitySchemaName": "UsrAccountWidgets", "filter": { "detailColumn": "UsrAccount", "masterColumn": "Id" } } }
If you want to wire up a method to get add/edit/delete events from this detail, all you need to do is add a “subscriber” to that detail definition with the name of a method to receive the events. The above will look like this with that added:
details: /**SCHEMA_DETAILS*/{ "AccountWidgets7f8633dc": { "schemaName": "AccountAddressDetailV2", "entitySchemaName": "UsrAccountWidgets", "filter": { "detailColumn": "UsrAccount", "masterColumn": "Id" }, "subscriber": { "methodName": "onWidgetDetailEvent" } } }
Now, when a row is added, edited, or deleted from that detail, it will call our method named “onWidgetDetailEvent”. We will also get passed a parameter, which will be an object with two properties: (1) “action” – this will have a value of either “edit” for add/edit or “delete” and (2) a property named “rows” – this is an array of Id string values that were added/edited (in the case of a delete, this array will be undefined). Here’s an example of that object you’ll be passed:
{ action: "edit", rows: [ "70f53c5c-a392-4cd2-a061-2d7973e57e9d" ] }
Now, all you need to do is make sure you’ve added the method you added as the detail subscriber in the methods section. The function would look like this:
onWidgetDetailEvent: function(args) { // a widget record has been added, edited, or deleted // now you can do whatever is needed here // for example: if (args.action == "edit") { console.log("Row with Id of " + args.rows[0] + " was edited"); } }
This function will be invoked each time a row is added, edited, or deleted in the detail
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!