How to create a field with a non-required formula
Hello - - this is a newbie question. I've coded a formula field to calculate a rush fee based on a standard 40% surcharge, but I'd like to be able to manually enter an amount if I give the client a reduced fee. Right now I'm using
if 'Rush?' = true then 'Final cost' * 0.4 else 0 end
Is there a way to adapt this so I can enter a value that's not validated by the formula? Or do I have to use multiple fields to do this? Thank you!
4 replies
-
You could put your code in the "Trigger after update" property of your Rush? field and have your code assign a value to the 'Final Cost' number field.
-
Thank you, Choices Software, but I'm not sure I completely follow - - and I also think I wasn't entirely clear. I have three fields:
'Rush?'
'Final cost' and
'Rush fee' (which is a percentage of "Final Cost' and which I need to show as a separate line on my invoices).
If I understand your suggestion, it still seems that I'd wind up with a calculation auto-populating 'Rush fee'. I've now tried setting 'Rush?' as a nonrequired combo box with two options, "Regular" and "Special" and coding it to
Trigger after update: if 'Rush' = "Regular" then 'Rush fee' = 'Final cost' * .4 - - but I can't figure out how to code else 'Rush fee' stays writable (which would allow me to manually enter an alternate discount).
I also can't seem to get the code to recognize the field value "Regular". It feels like I'm going about this all wrong, and I also think I'm just not getting the syntax right. I've read through the manual but it seems to assume some fundamental knowledge of coding that I lack.
-
Add the below to the "Trigger after update" of both the Rush? and Rush fee fields:
if text('Rush?') = "Special" then
'Final cost' := Cost * 'Rush fee'
else
'Final cost' := Cost
end
The Rush? field is a choice data type. You may need to tinker with the code to get it to work exactly the way you want, but the above should get you going. Note: above includes a cost field (which can be hidden).
-
I see! Thank you - - I've got it doing exactly what I want now. Much appreciated!
Content aside
- 4 yrs agoLast active
- 4Replies
- 796Views