어느 Salesforce Developer의 개발 성장기

Developer Console 기본편(2)-Navigate and Edit Source Code 본문

Salesforce/Developer Tools

Developer Console 기본편(2)-Navigate and Edit Source Code

Developer_Foryou 2020. 3. 8. 01:47

Create and Execute apex code

  • Create an Apex Class
    • Apex는 Org의 비즈니스 프로세스를 사용자 정의하는 데 사용할 수 있는 Salesforce 프로그래밍 언어이다.
    • Lighting Platform API에 대한 호출과 함께 Lightning Platform 서버에서 Flow 및 Transaction 제어문을 실행할 수 있도록 유형화된 객체지향언어를 호출할 수 있다.
    • JAVA와 비슷하며 org의 데이터와 상호 작용하는 프로그래밍 언어이다.
    • Apex Class 생성 : File > New > Apex Class에서 만들 수 있다.
    • Apex Class 소스코드 확인: File > Open에서 원하는 소스코드를 확인할 수 있다.
    • ex)
public class EmailMissionSpecialist {
      // Public method
      public void sendMail(String address, String subject, String body) {
          // Create an email message object
          Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
          String[] toAddresses = new String[] {address};
          mail.setToAddresses(toAddresses);
          mail.setSubject(subject);
          mail.setPlainTextBody(body);
          // Pass this email message to the built-in sendEmail method
          // of the Messaging class
          Messaging.SendEmailResult[] results = Messaging.sendEmail(
          new Messaging.SingleEmailMessage[] { mail });
          // Call a helper method to inspect the returned results
          inspectResults(results);
      }
      // Helper method
      private static Boolean inspectResults(Messaging.SendEmailResult[] results) {
          Boolean sendResult = true;
          // sendEmail returns an array of result objects.
          // Iterate through the list to inspect results.
          // In this class, the methods send only one email,
          // so we should have only one result.
          for (Messaging.SendEmailResult res : results) {
              if (res.isSuccess()) {
                  System.debug('Email sent successfully');
              }
              else {
                  sendResult = false;
                  System.debug('The following errors occurred: ' + res.getErrors());
              }
          }
          return sendResult;
      }
  }
  • Execute an Apex Class
    • Debug > Open Execute Anonymous Window를 실행하여, Apex Code를 실행시킬 수 있다.
    • ex)
    EmailMissionSpecialist em = new EmailMissionSpecialist();
    em.sendMail('Enter your email address', 'Flight Path Change', 'Mission Control 123: Your flight path has been changed to avoid collision '+ 'with asteroid 2014 QO441.');

Create aura Components

  • What are Lighting Components?
    • 모바일 및 데스크톱 앱을 개발하기 위한 Framework
    • Lightning Platform App에 대한 반응형 사용자 인터페이스를 만들 수 있다.
    • Lightning Component를 사용하면 모바일 및 데스크톱에서 원활하게 작동하는 앱을 보다 쉽게 만들 수 있다.
  • Create Aura Component
    • Lightning Component 생성 : File > New > Lightning Component에서 만들 수 있다.
      • 앱의 탭, 페이지, 레코드 페이지 및 커뮤니티 페이지를 구성하는 옵션을 결정할 수 있다.
        (이러한 옵션은 무시할 수 있다.)
      • 오른쪽 목록은 Component를 만드는 데 사용할 수 있는 Component Bundle의 Resource를 포함한다.

    • Lightning Component 소스코드 확인: File > Open Lightning Resources에서 원하는 Lightning Component를 확인할 수 있다.

Create visualforce pages and components

  • What is Visualforce?
    • Visualforce는 모바일 및 데스크톱 앱을 위한 사용자 인터페이스를 구축하기 위한 웹 개발 Framework.
    • Difference Visualforce and Lightning Component
      • Visualforce는 페이지 중심이다.
      • 레코드를 저장할 때 Visualforce 페이지는 서버와 상호작용하고 사용자 인터페이스를 다시 로드한다.
      • 반대로 Lightning Component는 Device에서 많은 일을 한다.
      • 더 자세한 내용은 Lightning Experience Development 확인
  • Create a Visualforce page
    • Visualforce Page 생성 : File > New > Visualforce Page에서 만들 수 있다.
    • Visualforce Page 소스코드 확인: File > Open에서 원하는 소스코드를 확인할 수 있다.
    • 좌측 상단의 Preview버튼을 클릭하여 페이지를 미리 확인 할 수 있다.

Comments