Note: This release is in preview. Features described here don’t become generally available until the latest general availability date that Salesforce announces for this release. Before then, and where features are noted as beta, pilot, or developer preview, we can’t guarantee general availability within any particular time frame or at all. Make your purchase decisions only on the basis of generally available products and features.
compileClasses()
Compile your Apex in Developer Edition or sandbox organizations.
Syntax
1CompileClassResult[] = compileClasses(string[] classList);Usage
Use this call to compile Apex classes in Developer Edition or sandbox organizations. Production organizations must use compileAndTest().
This call supports the DebuggingHeader and the SessionHeader.
Sample Code—Java
1public void compileClassesSample() {
2 String p1 = "public class p1 {\n"
3 + "public static Integer var1 = 0;\n"
4 + "public static void methodA() {\n"
5 + " var1 = 1;\n" + "}\n"
6 + "public static void methodB() {\n"
7 + " p2.MethodA();\n" + "}\n"
8 + "}";
9 String p2 = "public class p2 {\n"
10 + "public static Integer var1 = 0;\n"
11 + "public static void methodA() {\n"
12 + " var1 = 1;\n" + "}\n"
13 + "public static void methodB() {\n"
14 + " p1.MethodA();\n" + "}\n"
15 + "}";
16 CompileClassResult[] r = new CompileClassResult[0];
17 try {
18 r = apexBinding.compileClasses(new String[]{p1, p2});
19 } catch (RemoteException e) {
20 System.out.println("An unexpected error occurred: "
21 + e.getMessage());
22 }
23 if (!r[0].isSuccess()) {
24 System.out.println("Couldn't compile class p1 because: "
25 + r[0].getProblem());
26 }
27 if (!r[1].isSuccess()) {
28 System.out.println("Couldn't compile class p2 because: "
29 + r[1].getProblem());
30 }
31}Arguments
| Name | Type | Description |
|---|---|---|
| scripts | string | A request that includes the Apex classes and the values for any fields that need to be set for this request. |