You need to sign in to do that
Don't have an account?
Ram Shiva Kumar
Custom Settings Methods
Hi,
Can any body tell me the difference betwen the getvalues() and getinstance () methods customsettings.
Regards,
Siva.
Can any body tell me the difference betwen the getvalues() and getinstance () methods customsettings.
Regards,
Siva.
getInstance() gets you the merged values for all hierarchy levels above and including its argument (so if the user with id myUserId has a null value for a field, getInstance(myUserId) can inherit a value from the user's profile or the org-wide defaults)
getValues() gets you the record as specified for its argument (so if the user with id myUserId has a null value for a field, getValues(userId) will always have a null value for the field)
Thx,
Adrian
getValues() and getInstance() method will return identical values for list type custom setting.
But for the heirarchy type custom setting. getValues('XYZ') will return if any record is present for that user trying to access the value but getInstance('XYZ') will traverse up the heirarchy order and will return like if no record is present for the user trying to access the record but a Org wide default value is present then it will return OWD value but in this case getValue() will return null.
https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_methods_system_custom_settings.htm
Thanks,