Spring ’13 Force.com Platform Release Setting ID Fields for Updates Starting with Apex code saved using Salesforce.com API version 27.0, the Id field is now writeable on sObject instances for all sObject types—standard objects, custom objects, and generic sObjects—for update operations. The insert operation doesn’t support setting Id fields on sObjects. This change enables you to update existing records that correspond to sObject instances you already have, such as sObjects you obtained from deserializing JSON input. To do so, set the Id field on the sObjects to IDs of existing records in the database and call update. This call updates the corresponding records with all the other fields that are set on the sObjects.
月別アーカイブ: 8月 2013
通过外部ID项目来实现LOOKUP项目的ID自动设定
Account refAcct = new Account(externalId__c = ‘12345’);
Contact c = new Contact(Account = refAcct, LastName = ‘Kay’);
insert c;