23486 Posts in 18995 Topics by 2878 members
|Go to End|
16 July 2012 at 9:58pm
Just a couple of Questions not sure if what i'm trying to do can be done.
I have a Dataobject and a list of fields for the CMS a number of the fields contain a number for weight i need to have each of these fields query another table for a price and then calculate the weight*price and hold the answer for further calculations.
This is a small part of a rather long and complex formula that needs to return several parts.
my main question at the moment is can i add a query to the addfieldtotab in the getCMSFields function or will i have to write a seperate function for each field and then call it, or am i better making this portion of the dataobject a seperate data object and writing a single function to do this?
Although the last option may add complications to the rest of the formula.
17 July 2012 at 1:09am
Dataobject and a list of fields for the CMS a number of the fields contain a number for weight i need to have each of these fields query another table for a price and then calculate the weight*price and hold the answer for further calculations
This is a bit vague, but a suggestion might be to use the values in the onBeforeWrite to perform the calculation. you can add a literal field with the result int eh edit form that is shown only when this field has been calculated.
17 July 2012 at 10:48am
Thanks for the quick reply, I'm sorry if this was a bit vauge as i'm still getting some of it straight in my head.
this is part of a project that produces a quote for the application of Fertiliser, each quote has a recipe for the mix this is where the weights come in to it. Each component has a weight value and a price for that component.
At present i have the product and the price in a different table because they need to be updatable.
i need to have each component come up with a cost by weight e.g 10kg * price per Kg.
I am using this a start point because there are several other calculations involved as well.
this project only uses the CMS there are no front end components, and the results will need to be updatable if the recipe is changed as it will be adjusted during the quote process.
i think the queries will need to run each time the page is loaded because it will need to recalculate any changes, so the results will be stored in the session only? is this correct?
really i'm just not sure as to where the best place is to place the queries and the best method to use to get the right result i think that once i get this part going i should be able to figure the rest out .
Hope this Clears up what i'm trying to do
|Go to Top|