Forum Discussion
AlexCertificati
7 years agoQrew Cadet
What's the formula?
- WayneMajor7 years agoQrew Cadetvar number current = Nz([Total Quantity]);
var number received = Nz([Quantity Received]);
var number used = Nz([Quantity Used]); // Nz() will return the number if it isnt null, if it is then it will return 0.
var number total = $current + $received - $used;
$total - AlexCertificati7 years agoQrew CadetNothing obvious there. I would chase the bug upstream - what are the formulas/values in those three fields? There's a dependency in there somewhere that's either getting confused about a field to field relationship or else blanking out on you at some point for some reason.
- WayneMajor7 years agoQrew Cadet
The formula for the field Total Quantity is as follows:var date FirstDayOfTheMonth = FirstDayOfMonth(Today()) ;
The quantity Received as well as quantity used are just input fields that have no formula.
If(Today() = $FirstDayOfTheMonth or IsNull([Supply - Updated Quantity]), [Supply - Total Quantity] , [Supply - Updated Quantity] )
// If an order is being made at the beginning of the month, than the quantity will use the beginning month value, if the order is being made at any other date or if there is no updated quantity yet, the initial quantity will be used
The [Supply - Updated Quantity] field resides in the related table called Supply Record and will remain null until it is updated by a order in Supply Management.
[Supply - Updated Quantity] has a formula that looks like this:
_Starting out, this value should be null since it has yet to be updated, as a falisafe, the [Total Quantity (Beginning of the Month)] field is used in its place. Ive tried to cover all areas so that even if a field is left blank or null, there should always be some number being returned. The thing that really confuses me is that all my formulas are working as expected yet occasionally the [Current Quantity] field will simply not save the data it receives thorugh its formula, it WILL display it (sometimes), but if you exit the order or save it, and then go back into it the data for that field only will disappear and break everything.
[Order - Current Quantity] - AlexCertificati7 years agoQrew Cadet
occasionally the [Current Quantity] field will simply not save the data it receives thorugh its formula, it WILL display it (sometimes), but if you exit the order or save it, and then go back into it the data for that field only will disappear and break everything
Yeah. This is the classic behavior of a circular relationship. - WayneMajor7 years agoQrew CadetI redid the entire project and eventually got the entire thing to work properly without creating a circular relationship.
- AlexCertificati7 years agoQrew CadetHa, sure, "rebuild it from the ground up" is a good troubleshooting technique.
Glad you got it figured out!