function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
SteveMTCSteveMTC 

Custom Settings value get automatically over written?

Hi

 

I have a custom setting that contains the id of a custom field, so it can be referenced by some Apex to include as a url parameter. What's really strange is that I enter the id of the field (e.g. 00N200000025vSO) in the Name field of the custom setting, then pull this out in the apex and add '&' + fieldId + '=' + fieldvalue to a url for a pagereference, at which point I find that the value has changed to 00N200000025vSOMAA, which is actually the full correct 18-digit id for the field. This is incredibly annoying as it seems salesforce won't then pass the parameter to the field when these extra characters are included.

 

I know passing url parameters to non-standard fields is not a salesforce supported method, but the problem is coming from when I retrieve the value from the custom setting - if I query the value in the eclipse IDE, it's correct, but when I retrieve it in the Apex code, it automatically changes?!

 

Does anybody know what is going on or any way round it?

 

Thanks

 

Steve

SteveMTCSteveMTC

Ok, well I've found a way round it by querying the values rather than using the getAll() method, although it's annoying I have to use up a SOQL query to get the information, as that seems to negate the reason for using custom settings...

TomSnyderTomSnyder

if you dont want to burn a sql call do a fieldid.substring(0,15) in apex or use MID() in a  formula expression.Last time I used an Id in a custom setting, it would not let me use the ID as a name,   (I think it was caused cause the first char was a number, so my workaround was to prefix with a char and strip)  I guess this is now supported.