Percent field defaults (1 or 100)

  • 1
  • Problem
  • Updated 4 years ago
  • In Progress
I just spent an hour or so with a production bug involving temporary rows in a table. We have a field that indicates what percent of a line item should be applied to an invoice. Obviously this field is important to calculating our invoices accurately. My admin has told me with certainty that a PERCENT field with a default value of 1 will default to 100% in salesforce (I'm taking his word on this...). The field is set up like so:


However when users were creating new rows in the table of line items, the newly created line items were showing up as 1% instead of 100%. I logged the metadata of the field and it looks like skuid has it as "1.0" : 



Is this the correct behavior for a percent field?

Also before this release when a user created a new row (via a snippet) if there was no value sent in for the "Applies To" field, it would default to null. It seems like after superbank it started defaulting to the metadata default value. I know that is probably what most people want, but it my case it made some issues. Did something change in superbank about the way default values are set? 
Photo of Moshe Karmel

Moshe Karmel, Champion

  • 8,646 Points 5k badge 2x thumb

Posted 4 years ago

  • 1
Photo of Zach McElrath

Zach McElrath, Employee

  • 49,056 Points 20k badge 2x thumb
Moshe,

Thanks for reporting this.

In Superbank we started doing limited processing of default field values for Number, Percent, and Currency field values, which in past releases would have just had defaults of NULL because technically the Salesforce Schema information for these fields' getDefaultValue() is NULL --- what we had to do was to start using the getDefaultValueFormula() method instead.

You are correct, though, about there being a bug with Percent field default value handling --- apparently Salesforce expects Percent Field default values to be the decimal version of the percent, meaning that we need to multiply by 100. We'll get this rolled into our next patch release.

Zach