Salesforce - Apex
DML 문
- insert
- update
- upsert
- delete
- undelete
- merge (sObject 유형의 레코드를 최대 3개까지 하나로 병합 - 다른 레코드 삭제하고 관련 레코드 다시 상위항목으로 지정))
insert 하기
// Create the account sObject
Account acct = new Account(Name='Acme', Phone='(415)555-1212', NumberOfEmployees=100);
// Insert the account by using DML
insert acct;
sObject에서 ID가져오기
Account acct = new Account(Name='Acme', Phone='(415)555-1212', NumberOfEmployees=100);
insert acct;
// Get the new ID on the inserted sObject argument
ID acctID = acct.Id;
// Display this ID in the debug log
System.debug('ID = ' + acctID);
// Debug log result (the ID will be different in your case)
// DEBUG|ID = 001D000000JmKkeIAF
---
챌린지
Create a method for inserting accounts.
To pass this challenge, create an Apex class that inserts a new account named after an incoming parameter. If the account is successfully inserted, the method should return the account record. If a DML exception occurs, the method should return null.
- The Apex class must be called AccountHandler and be in the public scope
- The Apex class must have a public static method called insertNewAccount
- The method must accept an incoming string as a parameter, which will be used to create the Account name
- The method must insert the account into the system and then return the record
- The method must also accept an empty string, catch the failed DML and then return null
공부하면서 정리한 내용이므로 틀린 내용이 있을 수 있습니다.
틀린내용이 있다면 댓글 부탁드립니다.😊