Question

Handler dependant on Detail update

Hi

 

Usually I use the Handler method when I want to update field value depending on another field value when it changes.

 

For example:

dependencies: [

columns: ["Amount", "PaymentAmount"], 

methodName: "Calculate"    

 

The function "Calculate" will be triggered when columns "Amount" or "PaymentAmount" are changed.

 

My question is, how can I trigger a function when a change uccur on a detail, for example in the Products Details.

How can I activate the "Calculate" function when a change was made in the detail, for example, in the quantity of products?

 

Thanks,

Like 0

Like

2 comments

You can send a message via sandbox from the detail to the edit page to trigger the function. On the detail, override the onSaved function and send the message. On the edit page subscribe to the message and call your Calculate function. 

On the detail page:

messages: {
    "MyMessage": {
        mode: Terrasoft.MessageMode.BROADCAST,
        direction: Terrasoft.MessageDirectionType.PUBLISH
    }
},
methods: {
    onSaved: function(response, config) {
        this.sandbox.publish("MyMessage", null, [this.sandbox.id]);
        this.callParent(arguments);
    }
}

On the edit page with the Calculate message:

messages: {
    "MyMessage": {
        mode: Terrasoft.MessageMode.BROADCAST,
        direction: Terrasoft.MessageDirectionType.SUBSCRIBE
    }
},
methods: {
    init: function() {
        this.callParent(arguments);
 
        this.sandbox.subscribe("MyMessage", function(arg) {
            this.Calculate();
        }, this, [this.sandbox.id]);
    }
}

Ryan

Ryan Farley,

Thanks a lot Ryan !

Show all comments