Skip to main content

Timeline for How To Avoid Hard Coding ID

Current License: CC BY-SA 3.0

7 events
when toggle format what by license comment
Feb 6, 2017 at 20:00 comment added Bob Lopez Also keep in mind that you could be assigning the wrong record if there is ever a time when there is more than one Object1__c with the Name "DEF"
Feb 6, 2017 at 19:35 vote accept slsfrc
Feb 6, 2017 at 19:35 comment added slsfrc Thanks for helping. I have just tried your solution on my code. There's no problem so far. I will always take note of this. Thank you very much :)
Feb 6, 2017 at 19:31 comment added Curious Blueprints Absolutely true. In order to check for 0 results in #3 above, a list would definitely be the best solution. I was just trying to keep the code snippet as small as possible and use the criteria given.
Feb 6, 2017 at 19:27 comment added Adrian Larson Worth noting that when you query for a record, it's best to filter on a unique field. And if you are not certain it will exist, assign to a List.
Feb 6, 2017 at 19:26 history edited Curious Blueprints CC BY-SA 3.0
added explanation.
Feb 6, 2017 at 19:17 history answered Curious Blueprints CC BY-SA 3.0