카테고리 없음

[Apex Basics & Database] - Use sObjects (sObject 사용하기)

송테이토 2023. 1. 24. 18:45

 

what is sObject?

데이터베이스 테이블의 개체 -> 즉 자바의 Object랑 비슷하다.

Here are some common sObject type names in Apex used for standard objects.

  • Account
  • Contact
  • Lead
  • Opportunity

 

sObject 변수 생성

Account acct = new Account(Name='Acme', Phone='(415)555-1212', NumberOfEmployees=100);
Account acct = new Account();
acct.Name = 'Acme';
acct.Phone = '(415)555-1212';
acct.NumberOfEmployees = 100;

세일즈포스 API 이름 규칙

맞춤형 객체 및 사용자 정의 필드의 경우 API 이름은 항상 __c 접미사로 끝납니다.
사용자 정의 관계 필드의 경우 API 이름은 __r 접미사로 끝납니다. 

Merchandise라는 레이블이 있는 맞춤형 객체의 API 이름은 Merchandise__c입니다.
레이블이 설명인 사용자 정의 필드에는 API 이름이 Description__c입니다.
항목 레이블이 있는 사용자 정의 관계 필드의 API 이름은 Items__r입니다.

* 공백이면 _ 밑줄로 대체됨

 

 

 it can be of any persisted SFDC objects type.

For ex: Vehicle is generic type and Car, Motor Bike all are concrete types of Vehicle.

In SFDC,sObject is generic and Account, Opportunity, CustomObject__c are its concrete type.

Generic sObject abstracts the actual representation of any object assigned to it. sObject is the name of the generic abstract type that can be used to represent any persisted object type.

 

 

 

Quiz

+100 points
1Describe the relationship between sObjects and Salesforce records.
A.The name of an sObject field in Apex is the label of the field in Salesforce.
B.A custom object's API name and label are the same.
C.Every record in Salesforce is natively represented as an sObject in Apex.
-> 세일즈포스의 모든 레코드는 기본적으로 Apex에서 sObject로 표시된다.
2How do you create an sObject instance, such as an Account?
A.Declare a variable and assign a new sObject instance to it. ( 변수선언, 해당변수에 sObject 인스턴스 할당)
B.Use the sObject.newInstance() method.
C.Insert a persistent record into Salesforce using SOQL.
3Which of the following is correct about a generic sObject variable?
A.A generic sObject variable can be assigned only to another generic sObject.
B.Generic sObjects can't be created.
C.A generic sObject variable can be assigned to any specific sObject, standard or custom. Such as Account or Book__c.

 

Check the Quiz to Earn 100 Points
 

 


공부하면서 정리한 내용이므로 틀린 내용이 있을 수 있습니다.

틀린내용이 있다면 댓글 부탁드립니다.😊