Hello Community!
I would like execute a function to recalcule the Amount in Invoice after add a new Order (Detail)
I try with messages can't get a success.
Is a lookup detail. https://academy.bpmonline.com/documents/technic-sdk/7-12/adding-detail-lookup
Any example to make that?
Like
Hi Federico,
I think the fastest way you could do this is via a business process
Have a trigger start:
When Record is modified in any of the fields that would launch/initiate a recalculation (in my example it is PO Value, Payment Amount and Payment Status). Then you need to meet some type of filter condition and I usually do the the most important fields i am expecting the change in, in my example it is PO Value which i want to make sure is filled in.
Then simply build your business process around the start signal. Depending on where your "total" field is you could also use JS with the help from mixins. Or C# if you really want to make your life difficult, haha.
Hope this helps!
Philip I need make that in JavaScript because with BP can refresh de page to view the new amount. Exist a message in the detail page that send the event to subscribe: in the edit page? If can send this message willwork the subscribe: parameter on details atribute.
Federico, I see your point.
When I have previously done this with JavaScript I was pulling from a lookup and not a detail. My code would look something like the code below. This would just pull the code in then you would do your modification to the code. Maybe instead of creating column, creating virtual table, then summing column in table word work for you - though I am not sure how to do that.
"fieldName": { "dataValueType": this.Terrasoft.DataValueType.TEXT, "type": this.Terrasoft.ViewModelColumnType.ENTITY_COLUMN, "columnPath": "Order.Type.Name", "caption": {bindTo: "Resources.Strings.OrderTypeNameCaption"} }
Sorry I couldn't be anymore help!
Philip Wierciszewski,
For example when you make a delete in the detail. How the system execute the function in the subscriber?
Is that what i need. Execute the subscriber when a new record in the detail is added.
Dear Federico,
There are many examples that already present in the configuration. You can look at messages between OrderPageV2 and OrderProductDetailV2 in the Order package.
In the OrderPage:
messages: {
/**
* @message GetOrderProductSummary
* ########### ########## ### ###### ###### "########".
*/
"GetOrderProductSummary": {
mode: Terrasoft.MessageMode.PTP,
direction: Terrasoft.MessageDirectionType.SUBSCRIBE
},
...
methods: {
someMethod: function() {
this.sandbox.subscribe("GetOrderProductSummary", this.getProductSummaryConfig, this,
[this.getDetailId("ProductInProductsTab"), this.getDetailId("ProductInResultsTab")]);
...
}
In the OrderProductDetailV2:
messages: {
/**
* @message GetOrderProductSummary
* Returns information of product summary.
*/
"GetOrderProductSummary": {
mode: Terrasoft.MessageMode.PTP,
direction: Terrasoft.MessageDirectionType.PUBLISH
},
...
methods: {
someMethod: function() {
var summary = this.sandbox.publish("GetOrderProductSummary", null, [this.sandbox.id]);
...
}
You can learn more on the topic at our Academy here