I'm trying to create a formula field for pricing n...
# general
g
I'm trying to create a formula field for pricing needs. I'm trying to start with a base price and then add in additional upcharges based on certain conditions. The formula does not validate and don't think it's a typo. I'm afraid this approach simply isn't allowed. Any suggestions on a potential workaround?
CASE WHEN {custitem_product_tier} = 'HC1' THEN
24
CASE WHEN {custitem_x} = 'T' THEN + 10 END
CASE WHEN {custitem_record.field_1} = 'T' THEN + 5 END
CASE WHEN {custitem_record.field_2} = 'T' THEN + 21 END
CASE WHEN {custitem_record.field_3} = 'T' THEN + 12 END
CASE WHEN {custitem_record.field_4} = 'T' THEN + 26 END
END
c
@creece can you help my friend Greg?
c
Copy code
CASE WHEN {custitem_product_tier} = 'HC1' THEN {your_base_amount_field_id} 
CASE WHEN {custitem_x} = 'T' THEN ({your_base_amount_field} + 10)
CASE WHEN {custitem_record.field_1} = 'T' THEN ({your_base_amount_field_id} + 5)
CASE WHEN {custitem_record.field_2} = 'T' THEN ({your_base_amount_field_id} + 21)
CASE WHEN {custitem_record.field_3} = 'T' THEN ({your_base_amount_field_id} + 12)
CASE WHEN {custitem_record.field_4} = 'T' THEN ({your_base_amount_field_id} + 26) 
ELSE 0 END
Should be something like this or if each one can add, then it would be be something like:
Copy code
CASE WHEN {custitem_product_tier} = 'HC1' THEN {your_base_amount_field_id} 
CASE WHEN {custitem_x} = 'T' THEN ({your_base_amount_field} + 10)
CASE WHEN {custitem_record.field_1} = 'T' THEN ({your_base_amount_field_id} + 10 + 5)
CASE WHEN {custitem_record.field_2} = 'T' THEN ({your_base_amount_field_id} + 10 + 5 + 21)
CASE WHEN {custitem_record.field_3} = 'T' THEN ({your_base_amount_field_id} + 10 + 5 + 21 + 12)
CASE WHEN {custitem_record.field_4} = 'T' THEN ({your_base_amount_field_id} + 10 + 5 + 21 + 12 + 26) 
ELSE 0 END
I don't believe you can keep a value and increment it in a formula field so you'd have to add each prior value to the base. Someone may know a better way though.
Copy code
CASE <field> WHEN <condition1> THEN <value1> WHEN <condition2> THEN <value2> ELSE <value3> END
s
As @creece mentioned above, the THEN and ELSE parts all have to return a value (and they have to be of the same type, so if THEN returns a number, ELSE needs to as well. However, CASE statements can be part of an expression, so you should be able to do something like this:
Copy code
( CASE WHEN {custitem_product_tier} = 'HC1' THEN 24 ELSE 0 END
+ CASE WHEN {custitem_x} = 'T' THEN 10 ELSE 0 END
+ CASE WHEN {custitem_record.field_1} = 'T' THEN 5 ELSE 0 END
+ CASE WHEN {custitem_record.field_2} = 'T' THEN 21 ELSE 0 END
+ CASE WHEN {custitem_record.field_3} = 'T' THEN 12 ELSE 0 END
+ CASE WHEN {custitem_record.field_4} = 'T' THEN 26 ELSE 0 END )
That whole big expression should return a number between 0 and 98
c
Thanks guys.
g
Yeah - this is excellent food for thought. Still thinking through how I'll proceed. This might be better addressed via a m/r script where I can run this logic as needed across the items. Essentially the lack of the ability to set a variable and increment it with logic in a formula is the shortcoming.