Can't calculate the GST and Balance Pmt formula fields
Hello Friends ,
I can't wrap my head around this problem. I have four formula fields on the form
1. OrderCharges, 2. OrderTotal, 3. GST, 4. PmtBalance
Initially is was all good with OrderCharges, OrderTotal and GST
OrderCharges = sum(OrderItems.Subtotal)
OrderTotal = OrderCharges + DeliveryCharges
GST = OrderTotal / 11
Now I applied the styled() function on OrderCharges and OrderTotal. It returns a styled object, so I converted it into a number in the end. If I don't convert OrderCharges into a number, it given error while calculating OrderTotal (since OrderCharges is a styled object and I am trying to add DeliveryCharges to it to calculate OrderTotal).
After this the calculated values of OrderCharges and OrderTotal are showing fine in the formula fields, however it refuses to calculate the value of GST formula field and displays it as zero. Similarly it is not calculating the value of PmtBalance formula field as well. Some people make partial payments.
PmtBalance = number(OrderTotal) - PmtReceived
** Looks like internally it is taking the value of OrderTotal as null (I used If condition to check if OrderTotal is null, show an alert and the alert gets displayed every time even if the OrderTotal is showing a valid calculated value).
Code for OrderTotal formula field below:
let orderTotalAmount := 'Order Charges' + 'Delivery Charges' + Adjustment;
styled(text(orderTotalAmount), "#F7F8FC")
Code for PmtBalance formula field below:
if number('Order Total') = null then
0
else
number('Order Total') - 'Pmt Received'
end
Code for GST formula field below:
let GST := number('Order Total') / 11;
"(Includes GST of: " + GST + ")"
17 replies
-
This post explains why you can't use styled() data directly.
It seems kinda convoluted but I was able to get this to work:
Formula 2 is a field that sums then applies a style:
let x := sum('MTL ACTIVITY'.Quantity); styled(text(x), "green")
Then in another field I put this in the code.
let f := formatJSON('Formula 2'); let p := parseJSON(f); number(item(p, "text"))
Then it returns the value that was used in Formula 2. JSON always returns the data as any so I ended turning it back into a number.
Content aside
- 4 mths agoLast active
- 17Replies
- 76Views
-
3
Following