5
Using the Developer Console to Execute Apex Code  The Developer Console can look overwhelming , but it’s just a collection of tool s that help you work with code. In this lesson, you’ll eecute !pe code and view the results in the "og Inspector. The "og Inspector is a useful tool you’ll use often. #. Click Debug $ Open Execute Anonymous Window or CT%"&'. (. In th e 'nter !pe Co de wi ndow, enter the f ol lo wi ng tet) *ystem.debug+ -ello orld /0 *ystem.debug+/ is like using *ystem.out.println+/ in 1ava +or printf+/ if you’ve been around a while 02/. 3ut, when you’re coding in the cloud, where does the output go4 %ead on5 6. Deselect Open Log and then click Execute.

Using the Developer Console to Execute Apex Code

  • Upload
    ksr131

  • View
    222

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Using the Developer Console to Execute Apex Code

8/18/2019 Using the Developer Console to Execute Apex Code

http://slidepdf.com/reader/full/using-the-developer-console-to-execute-apex-code 1/5

Using the Developer Console to

Execute Apex Code The Developer Console can look overwhelming, but it’s just a collection of tools

that help you work with code. In this lesson, you’ll eecute !pe code and viewthe results in the "og Inspector. The "og Inspector is a useful tool you’ll useoften.

#. Click Debug $ Open Execute Anonymous Window or CT%"&'.

(. In the 'nter !pe Code window, enter the following

tet) *ystem.debug+ -ello orld /0

*ystem.debug+/ is like using *ystem.out.println+/ in 1ava +or printf+/ if you’ve beenaround a while 02/. 3ut, when you’re coding in the cloud, where does theoutput go4 %ead on5

6. Deselect Open Log and then click Execute.

Page 2: Using the Developer Console to Execute Apex Code

8/18/2019 Using the Developer Console to Execute Apex Code

http://slidepdf.com/reader/full/using-the-developer-console-to-execute-apex-code 2/5

'very time you eecute code, a log is created and listed in the Logs panel.

Double2click a log to open it in the "og Inspector. 7ou can open multiple logs at atime to compare results."og Inspector is a contet2sensitive eecution viewer that shows the source ofan operation, what triggered the operation, and what occurred afterward. 8sethis tool to inspect debug logs that include database events, !pe processing,work9ow, and validation logic.

 The "og Inspector includes prede:ned perspectives for speci:c uses.Click Debug $ Switch Perspective to select a di;erent view, or click CT%"&< toselect individual panels. 7ou’ll probably use the 'ecution "og panel the most. Itdisplays the stream of events that occur when code eecutes. 'ven a singlestatement generates a lot of events. The "og Inspector captures many eventtypes) method entry and eit, database and web service interactions, andresource limits. The event type 8*'%=D'38> indicates the eecution ofa *ystem.debug+/ statement.

Page 3: Using the Developer Console to Execute Apex Code

8/18/2019 Using the Developer Console to Execute Apex Code

http://slidepdf.com/reader/full/using-the-developer-console-to-execute-apex-code 3/5

#. Click Debug $ Open Execute Anonymous Window or CT%"&' and

enter the following code)

1 System.debug( 'Hello World' );

2 System.debug( System.now() );

3 System.debug( System.now() + 10 );

6. *elect Open Log and click Execute.

?. In the 'ecution "og panel, select Executble. This limits the display to

only those items that represent eecuted statements. @or eample, it :lters

out the cumulative limits.

A. To :lter the list to show only 8*'%=D'38> events, select Debug Only or

enter 8*'% in the !ilter:eld.

Page 4: Using the Developer Console to Execute Apex Code

8/18/2019 Using the Developer Console to Execute Apex Code

http://slidepdf.com/reader/full/using-the-developer-console-to-execute-apex-code 4/5

 The :lter tet is case sensitive.

CongratulationsByou have successfully eecuted code onthe @orce.com platform and viewed the results5

 Tell e ore...

-elp in the Developer Console

 To learn more about the Developer Console, click "elp $ "elp Docs# inthe Developer Console.

!nonymous 3locks

 The Developer Console allows you to eecute code statements on the 9y. 7ou can uickly evaluate the results in the Logs panel. The code that youeecute in the Developer Console is referred to as an anonymous block .!nonymous blocks run as the current user and can fail to compile if thecode violates the user’s object2 and :eld2level permissions. Eote that thisisn’t the case for !pe classes and triggers.