Skip to main content
9 events
when toggle format what by license comment
Apr 25, 2021 at 20:36 comment added Marcin Sz. @CPS it should not matter if the ID field is 15 or 18 format, it's transparent for the developer, although it might be not transparent in a certain custom implementation (but for sure it's not the right design). Please provide a wider context i.e. what is the contract for those unit tests you mentioned, and I think we'll be able to help you then.
Apr 22, 2021 at 21:33 comment added sfdcfox This is an X-Y Problem. If you're having ID problems in Apex, you're doing something wrong. Always use the Id data type instead of String, and always use the 18-character ID values.
Apr 22, 2021 at 13:10 comment added David Reed Any on-platform code that fails to be agnostic between 15 and 18 character Ids is broken and needs to be fixed.
Apr 22, 2021 at 13:03 comment added Phil W Since 15 and 18 are the same, I see no point in testing such conversion. I suggest you actually work with "Id" instances instead of Strings, since these will be agnostic of length.
Apr 22, 2021 at 12:49 comment added CPS So, is not possible to that ID change from 18 to 15? This is part of method of TestClass, and I need it to testing functionality of external methods. In those external methods, code searches for ID 15 characters in MAP, and, if it does not find it, code fails... So, test fails because of it.
Apr 22, 2021 at 12:41 comment added Phil W I suspect System.debug simply always outputs IDs in the 18 character format, but I've never specifically checked.
Apr 22, 2021 at 12:39 comment added Phil W 15 and 18 character IDs are entirely equivalent. 15 character variants are case sensitive, whilst the 18 character equivalents are case insensitive (so work even if you lowercase the ID content). Why are you trying to do what you're doing?
Apr 22, 2021 at 12:21 history edited Derek F CC BY-SA 4.0
Fixed code formatting
Apr 22, 2021 at 11:44 history asked CPS CC BY-SA 4.0