Dear folks, I've two decimal type fields in a table and I've created a new one that has to multiply these two. The code is simply:
Result field:=("field one")*("fields two");
I put it on validate trigger from field one and field two.
If you write manually in these fields the result field changes, it runs well; but if the quantities change during any proces the result filed remains with the last quantities. I suppose that I have to do somenthig on the table to be continually updating this field. Any idea please?.
Thanks in advance for help.
0
Comments
RIS Plus, LLC
you should change it to VALIDATE function unleash the power ( :!: :!: ) of OnValidate trigger... the ":=" does not. this is an important and basic difference a nav developer should know...remember it!
EDIT: i've seen denster answered before me after clicking "submit", but hey...i can't waste my already written post, isn't it?
"Never memorize what you can easily find in a book".....Or Mibuso
My Blog
Thanks for help.
"Never memorize what you can easily find in a book".....Or Mibuso
My Blog
Table Bom component. First field is "Quantity per" and second field it's "Order quantity", it's a flowfield that I've created. I want to multiply "Quantity per" by "Order quantity" and show the result in "Total quantity", it's a field that I've created also.
When quantity on "Quantity per" field changes "Total quantity" do correctly the operation and show the result, but not when changes the quantity form "Order quantity" field; I supposed that it was because was a flowfield, but I've put the calcfields instruction but the result is the same. Any idea please?.
Thanks for help.
"Quantity per" --> not flowfield, input by process
"Order quantity" --> flowfield, therefore it's calculated by the system
"Total quantity" --> it's "quantity per"*"order quantity", shouldn't be a flowfield
Order quantity must be calculated with calcfields before doing the moltiplication, if the situation is the one shown in this post
"Never memorize what you can easily find in a book".....Or Mibuso
My Blog
bomtable.CALCFIELDS("Order quantity");
"Total quantity":=("Order quantity")*("Quantity per");
I cant' find the problem.
Thanks.
change your code to
"Never memorize what you can easily find in a book".....Or Mibuso
My Blog
CALCFIELDS; <- To calculate any flowfields you need.
Field.VALIDATE; <- To fill your value and call the validation code.
Rec.MODIFY; <- To save your changes on the record.
Debug your code. Place a breakpoint at the line where you fill the value and see step by step what happens.
Thanks for help.
Have you debugged it to see what happens?
The code can be anywhere depending on your design.
The modify could be on your process.
CALCFIELDS("Order quantity");
"Total quantity":=("Order quantity")*("Quantity per");
But the result is the same, when "Order quantity" changes "Total quantity" doesn't change. I also active the debugger but I don't see anything strange. Any idea please?
Can you post the whole code you have in the onaftergetrecord trigger under the form, please?
"Never memorize what you can easily find in a book".....Or Mibuso
My Blog
Thanks for reply.
after rereading all the posts, i realized that you have no problems with the form, so, don't mind...
debug your code and see what happens, it's the only thing i can say, as i don't have the whole picture of your code...
"Never memorize what you can easily find in a book".....Or Mibuso
My Blog
Thanks for your help.
"Never memorize what you can easily find in a book".....Or Mibuso
My Blog
"Never memorize what you can easily find in a book".....Or Mibuso
My Blog
Thanks.
"Never memorize what you can easily find in a book".....Or Mibuso
My Blog
Well, thank you very much for your help and time.
in the case when FlowField Functionality is changing the value of the FlowField there I think is no trigger which is initiated. You are not able to react on this event like in "OnValidate"-Trigger.
So if I understand what should be: Updating a RecordLine in Subform should initiate updating your "Total Quantity" in Record which is shown in the Mainform, right?
So maybe it's the issue of "Updating Mainform out of the subform"?
A poor solution may be creating a timer which ongoing checks the "Total Quantity" if it is still the product of "Order Quantity" and "Quantity per". Another solution may be using the Automation XMLDom. This you may find by searching the forum. It's like: Change in subform initiates sth in XMLDom and Mainform reacts on the event. This is not simple but it's working...
As the onvalidate of the flowfield is not called implicitly when it changes the value, you have to explicitly validate it in order to do the moltiplication in the trigger, or do the calculation manually everytime the source value of the flowfield (the outstanding quantity) changes...
"Never memorize what you can easily find in a book".....Or Mibuso
My Blog
another issue in this forum is nearly the same problem.
What about calculating the product out of the OnValidate-Trigger of the Field which is referenced by the FlowField? Means in SourceField which dynamically gives value to the FlowField. This is in another table but I think it should be possible to reference to the table which owns the FlowField, make a CALCFIELDS-statement, compute product and modify the table...
I didn't try it by myself ... if anyone tries it please post result...
"Never memorize what you can easily find in a book".....Or Mibuso
My Blog
MODIFY
instead of
MODIFY(TRUE)
the onmodify trigger is not fired...
"Never memorize what you can easily find in a book".....Or Mibuso
My Blog