You need to sign in to do that
Don't have an account?
szesze21
sObjects topic on Trailhead
On https://developer.salesforce.com/trailhead/apex_database/apex_database_sobjects, it gives 2 examples on how to populate fields on a new record: is either one better than the other, in terms of taking up memory, or any governance limits? thanks.
1) Account acct = new Account(Name='Acme', Phone='(415)555-1212', NumberOfEmployees=100); OR
2) Alternatively, you can use the dot notation to add fields to an sObject. The following is equivalent to the previous example, although it takes a few more lines of code.view source
print?
Account acct = new Account();
acct.Name = 'Acme';
acct.Phone = '(415)555-1212';
acct.NumberOfEmployees = 100;
1) Account acct = new Account(Name='Acme', Phone='(415)555-1212', NumberOfEmployees=100); OR
2) Alternatively, you can use the dot notation to add fields to an sObject. The following is equivalent to the previous example, although it takes a few more lines of code.view source
print?
Account acct = new Account();
acct.Name = 'Acme';
acct.Phone = '(415)555-1212';
acct.NumberOfEmployees = 100;
Both are better, as earlier salesforce have script statment limits, at that time first was preferable but now salesforce has removed this limit, so you can go ahead with any approach.
Also, you can use variables in both the approaches.
If this help, you can mark it as best answer.
Thanks,
Neetu