Hi
Need a little help to achieve fields calculation (maybe with Hooks?).
I need to take 2 or more fields, do some math and write the result to another data collection field (like excel sheet, field1 - field 3 = 5 than write the answer to field6.
Is there any way to do this with hooks?.
What is the trigger for the hook? I need it to do the calculation at any time that some field is changing.
Thanks a lot.
Hi
Thank you, i found a very simple way to solve it by using hooks:
export function mydataset_beforeInsert(item, context) {
var entry = item.entry
var stop = item.stop
item.risk = entry - stop;
//Adding sum value to the inserted record:
return item;
}
but now i have another problem, i can’t find a way to Update an existing field in a data collection.
my website can track users stock trading positions, so user will enter the entry price and once he close the position, he will write the current price and i will calculate the reward.
for example, the user buy a stock at 20$ and he add that data to the database.
few days later the user sold the stock at price of 25$.
the entry price (20$) is already in my database, how can i let the user to enter only the selling price and i will automatically calculate the selling price - entry price?.
I’m trying to use Hook but i can’t find a way to new record to an existing record.
Thank you!.