forrest
forrest copied to clipboard
Storing integer IDs in a Salesforce Custom Field with Number type
When you create a custom field of type Number in Salesforce, Forrest always returns a PHP float for that field. This means you can't reliably store IDs in a Number field because if you save "123", Forrest returns it as "123.0". Example:
>>> $myId = 123
=> 123
>>> Forrest::sobjects("Opportunity/xyz123", ["method" => "patch", "body" => ["myId__c" => $myId]])
=> null
>>> $gotId = Forrest::sobjects("Opportunity/xyz123")['myId__c']
=> 123.0
>>> $gotId === $myId
=> false
While I think this is correct for Number custom fields that have a scale >= 1, I would argue that if the scale of a number custom field is set to 0, Forrest should return an int, not a float.