stb-kslater3 / Admin_Checklist

Tool used by Sales Team to determine Quotes, and other things
0 stars 0 forks source link

Can't Remove a Saved Value #3

Closed stb-kslater3 closed 3 years ago

stb-kslater3 commented 3 years ago

Currently the update/insert only appends the value to a field if it isn't falsey, and empty strings evaluate to falsy, so let's say I want to remove a Description so I go delete out that comment. When I save it saves, but it never used that empty comment field because it is falsy. So the comment still is there and is not saved as an empty string instead. The other problem is that if you try and save it as an empty string then Apex will throw an error when you try to either insert or update because it cannot convert ' ' to a decimal or something like that, for some fields that don't have a value.

stb-kslater3 commented 3 years ago

So the problem from digging a little deeper, is that if I say in appendFieldValuePairs() to also consider when the element's value is '' then description work fine, but in Trade In ACV is not defaulted to 0.00 and is instead ''. So then when it goes to save it hits the '' of a decimal/currency type and says hey I can't make this empty string a decimal. The only reason other money values weren't throwing an error is because they have 0.00 for defaults and so it works out. I don't want to just add a default value to Trade In, so I will think more about how to fix this for good, but will also put a default value of 0.00 for Trade In.

stb-kslater3 commented 3 years ago

Well, for now I set the default value for Trade In, and am good to go. I also had to make sure to allow 0, because it is treated as falsy too.