{"id":3638,"date":"2023-11-21T14:39:21","date_gmt":"2023-11-21T06:39:21","guid":{"rendered":"http:\/\/www.ponybai.com\/?p=3638"},"modified":"2023-11-21T15:02:54","modified_gmt":"2023-11-21T07:02:54","slug":"apex-%e6%b3%a8%e8%a7%a3","status":"publish","type":"post","link":"http:\/\/www.ponybai.com\/?p=3638","title":{"rendered":"Apex \u6ce8\u89e3"},"content":{"rendered":"\n<h1 class=\"wp-block-heading\">\u9644\u6ce8<\/h1>\n\n\n\n<p>Apex \u6ce8\u89e3\u4fee\u6539\u4e86\u65b9\u6cd5\u6216\u7c7b\u7684\u4f7f\u7528\u65b9\u5f0f\uff0c\u7c7b\u4f3c\u4e8e Java \u4e2d\u7684\u6ce8\u89e3\u3002\u6ce8\u91ca\u4f7f\u7528\u521d\u59cb\u7b26\u53f7\u5b9a\u4e49\uff0c\u540e\u8ddf\u76f8\u5e94\u7684\u5173\u952e\u5b57\u3002<\/p>\n\n\n\n<p><samp>@<\/samp><\/p>\n\n\n\n<p>\u82e5\u8981\u5411\u65b9\u6cd5\u6dfb\u52a0\u6279\u6ce8\uff0c\u8bf7\u5728\u65b9\u6cd5\u6216\u7c7b\u4e4b\u524d\u6307\u5b9a\u5b83 \u5b9a\u4e49\u3002\u4f8b\u5982\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>global class MyClass {\n     @Future\n     Public static void myMethod(String a)\n     {\n          \/\/long-running Apex code\n     }\n}<\/code><\/pre>\n\n\n\n<p>Apex \u652f\u6301\u4ee5\u4e0b\u6ce8\u89e3\u3002<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><samp>@AuraEnabled<\/samp><\/li>\n\n\n\n<li><samp>@Deprecated<\/samp><\/li>\n\n\n\n<li><samp>@Future<\/samp><\/li>\n\n\n\n<li><samp>@InvocableMethod<\/samp><\/li>\n\n\n\n<li><samp>@InvocableVariable<\/samp><\/li>\n\n\n\n<li><samp>@IsTest<\/samp><\/li>\n\n\n\n<li><samp>@JsonAccess<\/samp><\/li>\n\n\n\n<li><samp>@NamespaceAccessible<\/samp><\/li>\n\n\n\n<li><samp>@ReadOnly<\/samp><\/li>\n\n\n\n<li><samp>@RemoteAction<\/samp><\/li>\n\n\n\n<li><samp>@SuppressWarnings<\/samp><\/li>\n\n\n\n<li><samp>@TestSetup<\/samp><\/li>\n\n\n\n<li><samp>@TestVisible<\/samp><\/li>\n\n\n\n<li>Apex REST\u6ce8\u89e3\uff1a\n<ul class=\"wp-block-list\">\n<li><samp>@ReadOnly<\/samp><\/li>\n\n\n\n<li><samp>@RestResource(urlMapping=&#8217;\/<var>yourUrl<\/var>&#8216;)<\/samp><\/li>\n\n\n\n<li><samp>@HttpDelete<\/samp><\/li>\n\n\n\n<li><samp>@HttpGet<\/samp><\/li>\n\n\n\n<li><samp>@HttpPatch<\/samp><\/li>\n\n\n\n<li><samp>@HttpPost<\/samp><\/li>\n\n\n\n<li><samp>@HttpPut<\/samp><\/li>\n<\/ul>\n<\/li>\n<\/ul>\n\n\n\n<ol class=\"wp-block-list\">\n<li>AuraEnabled \u6ce8\u89e3<\/li>\n\n\n\n<li>\u5df2\u5f03\u7528\u7684\u6279\u6ce8<\/li>\n\n\n\n<li>\u672a\u6765\u6ce8\u89e3<\/li>\n\n\n\n<li>InvocableMethod \u6ce8\u89e3 \u4f7f\u7528\u6ce8\u89e3<br>\u6765\u6807\u8bc6\u53ef\u4f5c\u4e3a\u53ef\u8c03\u7528\u64cd\u4f5c\u8fd0\u884c\u7684\u65b9\u6cd5\u3002<samp>InvocableMethod<\/samp><\/li>\n\n\n\n<li>InvocableVariable \u6279\u6ce8<br>\u4f7f\u7528\u6279\u6ce8\u6765\u6807\u8bc6\u81ea\u5b9a\u4e49\u7c7b\u4e2d\u53ef\u8c03\u7528\u65b9\u6cd5\u4f7f\u7528\u7684\u53d8\u91cf\u3002<samp>InvocableVariable<\/samp><\/li>\n\n\n\n<li>IsTest \u6ce8\u89e3<\/li>\n\n\n\n<li>JsonAccess \u6ce8\u89e3<\/li>\n\n\n\n<li>NamespaceAccessible \u6279\u6ce8<\/li>\n\n\n\n<li>ReadOnly \u6ce8\u91ca<\/li>\n\n\n\n<li>RemoteAction \u6279\u6ce8<\/li>\n\n\n\n<li>SuppressWarnings&nbsp;\u6ce8\u91ca<br>\u6b64\u6ce8\u91ca\u5728 Apex \u4e2d\u4e0d\u6267\u884c\u4efb\u4f55\u64cd\u4f5c\uff0c\u4f46\u53ef\u7528\u4e8e\u5411\u7b2c\u4e09\u65b9\u5de5\u5177\u63d0\u4f9b\u4fe1\u606f\u3002<\/li>\n\n\n\n<li>TestSetup \u6279\u6ce8 \u4f7f\u7528\u6279\u6ce8<br>\u5b9a\u4e49\u7684\u65b9\u6cd5\u7528\u4e8e\u521b\u5efa\u53ef\u7528\u4e8e\u7c7b\u4e2d\u6240\u6709\u6d4b\u8bd5\u65b9\u6cd5\u7684\u901a\u7528\u6d4b\u8bd5\u8bb0\u5f55\u3002<samp>@TestSetup<\/samp><\/li>\n\n\n\n<li>TestVisible \u6ce8\u89e3<\/li>\n<\/ol>\n\n\n\n<h1 class=\"wp-block-heading\">AuraEnabled\uff08Lightning\u542f\u7528\uff09\u6ce8\u89e3<\/h1>\n\n\n\n<p><a><\/a>\u8be5\u6ce8\u91ca\u652f\u6301\u5ba2\u6237\u7aef\u548c\u670d\u52a1\u5668\u7aef\u8bbf\u95ee Apex \u63a7\u5236\u5668\u65b9\u6cd5\u3002 \u63d0\u4f9b\u6b64\u6ce8\u91ca\u540e\uff0c\u60a8\u7684\u65b9\u6cd5\u53ef\u7528\u4e8e Lightning \u7ec4\u4ef6 \uff08Lightning Web \u7ec4\u4ef6\u548c Aura \u7ec4\u4ef6\uff09\u3002\u53ea\u6709\u8fd9\u4e2a\u65b9\u6cd5 \u6ce8\u89e3\u662f\u516c\u5f00\u7684\u3002<samp>@AuraEnabled<\/samp><\/p>\n\n\n\n<p>\u5728 API \u7248\u672c 44.0 \u53ca\u66f4\u9ad8\u7248\u672c\u4e2d\uff0c\u60a8\u53ef\u4ee5\u901a\u8fc7\u7f13\u5b58\u65b9\u6cd5\u63d0\u9ad8\u8fd0\u884c\u65f6\u6027\u80fd \u4f7f\u7528\u6ce8\u91ca\u5728\u5ba2\u6237\u7aef\u4e0a\u751f\u6210\u7ed3\u679c\u3002\u60a8\u53ea\u80fd\u7f13\u5b58\u4ee5\u4e0b\u65b9\u6cd5\u7684\u7ed3\u679c \u68c0\u7d22\u6570\u636e\u4f46\u4e0d\u4fee\u6539\u6570\u636e\u7684\u65b9\u6cd5\u3002\u4f7f\u7528\u6b64\u6ce8\u89e3\u53ef\u6d88\u9664 \u9700\u8981\u8c03\u7528 JavaScript \u4ee3\u7801 \u5728\u8c03\u7528 Apex \u65b9\u6cd5\u7684\u6bcf\u4e2a\u64cd\u4f5c\u4e0a\u3002<samp>@AuraEnabled(cacheable=true)<\/samp><samp>setStorable()<\/samp><\/p>\n\n\n\n<p>\u5728 API \u7248\u672c 55.0 \u53ca\u66f4\u9ad8\u7248\u672c\u4e2d\uff0c\u60a8\u53ef\u4ee5\u4f7f\u7528\u6ce8\u91ca\u4f7f Apex \u65b9\u6cd5\u6210\u4e3a \u7f13\u5b58\u5728\u5168\u5c40\u7f13\u5b58\u4e2d\u3002<samp>@AuraEnabled(cacheable=true&nbsp;scope=&#8217;global&#8217;)<\/samp><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\u7248\u672c\u5316\u884c\u4e3a\u66f4\u6539<\/h2>\n\n\n\n<p>\u5728 API \u7248\u672c 55.0 \u53ca\u66f4\u9ad8\u7248\u672c\u4e2d\uff0c\u4e0d\u5141\u8bb8\u5bf9\u5e26\u6709 \u6ce8\u91ca\u7684\u65b9\u6cd5\u8fdb\u884c\u91cd\u8f7d\u3002<samp>@AuraEnabled<\/samp><\/p>\n\n\n\n<h1 class=\"wp-block-heading\">\u5e9f\u5f03\u7684\u6ce8\u89e3<\/h1>\n\n\n\n<p>\u4f7f\u7528\u6ce8\u91ca\u6765\u6807\u8bc6\u65b9\u6cd5\u3001\u7c7b\u3001\u5f02\u5e38\u3001\u679a\u4e3e\u3001 \u63a5\u53e3\u6216\u53d8\u91cf\uff0c\u8fd9\u4e9b\u63a5\u53e3\u6216\u53d8\u91cf\u5728\u540e\u7eed\u7248\u672c\u7684&nbsp;\u88ab\u7ba1\u7406&nbsp;\u5b83\u4eec\u6240\u5728\u7684\u5305\u3002\u6b64\u6ce8\u91ca\u5728\u4ee5\u4e0b\u60c5\u51b5\u4e0b\u5f88\u6709\u7528 \u968f\u7740\u9700\u6c42\u7684\u53d1\u5c55\u91cd\u6784\u6258\u7ba1\u5305\u4e2d\u7684\u4ee3\u7801\u3002\u65b0\u8ba2\u9605\u8005 \u770b\u4e0d\u5230\u5df2\u5f03\u7528\u7684\u5143\u7d20\uff0c\u800c\u8fd9\u4e9b\u5143\u7d20\u7ee7\u7eed\u8fd0\u884c \u73b0\u6709\u8ba2\u9605\u8005\u548c API \u96c6\u6210\u3002<samp>Deprecated<\/samp><\/p>\n\n\n\n<p>\u4ee5\u4e0b\u4ee3\u7801\u7247\u6bb5\u663e\u793a\u4e86\u5df2\u5f03\u7528\u7684\u65b9\u6cd5\u3002\u4e00\u6837 \u8bed\u6cd5\u53ef\u7528\u4e8e\u5f03\u7528\u7c7b\u3001\u5f02\u5e38\u3001\u679a\u4e3e\u3001\u63a5\u53e3\u3001 \u6216\u53d8\u91cf\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>@Deprecated\n  \/\/ This method is deprecated. Use myOptimizedMethod(String a, String b) instead.\n  global void myMethod(String a) {\n   \n}<\/code><\/pre>\n\n\n\n<p>\u5f03\u7528 Apex \u6807\u8bc6\u7b26\u65f6\uff0c\u8bf7\u6ce8\u610f\u4ee5\u4e0b\u89c4\u5219\uff1a<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u975e\u6258\u7ba1\u5305\u4e0d\u80fd\u5305\u542b\u4f7f\u7528\u5173\u952e\u5b57\u7684\u4ee3\u7801\u3002<samp>deprecated<\/samp><\/li>\n\n\n\n<li>\u5f53 Apex \u9879\u88ab\u5f03\u7528\u65f6\uff0c\u5f15\u7528\u5df2\u5f03\u7528\u7684 Apex \u9879\u7684\u6240\u6709<samp>\u5168\u5c40<\/samp>\u8bbf\u95ee\u4fee\u9970\u7b26 \u6807\u8bc6\u7b26\u4e5f\u5fc5\u987b\u5f03\u7528\u3002\u4efb\u4f55\u5728\u5176\u4e2d\u4f7f\u7528\u5f03\u7528\u7c7b\u578b\u7684\u5168\u5c40\u65b9\u6cd5 \u8fd8\u5fc5\u987b\u5f03\u7528\u8f93\u5165\u53c2\u6570\u6216\u65b9\u6cd5\u8fd4\u56de\u7c7b\u578b\u4e2d\u7684\u7b7e\u540d\u3002\u5df2\u5f03\u7528\u7684\u9879\uff08\u5982\u65b9\u6cd5\u6216\u7c7b\uff09\u53ef\u4ee5 \u4ecd\u7531\u5305\u5f00\u53d1\u4eba\u5458\u5728\u5185\u90e8\u5f15\u7528\u3002<\/li>\n\n\n\n<li><samp>webservice<\/samp>\u65b9\u6cd5\u548c\u53d8\u91cf\u4e0d\u80fd\u662f \u8352\u5e9f\u7684\u3002<\/li>\n\n\n\n<li>\u60a8\u53ef\u4ee5\u5f03\u7528 \uff0c\u4f46\u4e0d\u80fd\u5f03\u7528 \u4e2a\u4eba\u4ef7\u503c\u3002<samp>enum<\/samp><samp>enum<\/samp><\/li>\n\n\n\n<li>\u53ef\u4ee5\u5f03\u7528\u63a5\u53e3\uff0c\u4f46\u4e0d\u80fd\u5f03\u7528\u63a5\u53e3\u4e2d\u7684\u5355\u4e2a\u65b9\u6cd5\u3002<\/li>\n\n\n\n<li>\u60a8\u53ef\u4ee5\u5f03\u7528\u62bd\u8c61\u7c7b\uff0c\u4f46\u4e0d\u80fd\u5f03\u7528 \u62bd\u8c61\u7c7b\u3002<\/li>\n\n\n\n<li>\u60a8\u65e0\u6cd5\u5220\u9664\u6279\u6ce8 \u5728\u53d1\u5e03\u8f6f\u4ef6\u5305\u7248\u672c\u540e\uff0c\u53d6\u6d88\u5f03\u7528 Apex \u4e2d\u7684\u67d0\u4e9b\u5185\u5bb9\uff0c\u5176\u4e2d Apex \u4e2d\u7684\u9879\u5df2\u5f03\u7528\u3002<samp>Deprecated<\/samp><\/li>\n<\/ul>\n\n\n\n<p>\u6709\u5173\u5305\u7248\u672c\u7684\u8be6\u7ec6\u4fe1\u606f\uff0c\u8bf7\u53c2\u9605\u4ec0\u4e48\u662f\u5305\uff1f\u3002<\/p>\n\n\n\n<h1 class=\"wp-block-heading\">\u672a\u6765\u7684\u6ce8\u89e3<\/h1>\n\n\n\n<p id=\"future_defn\"><a><\/a>\u4f7f\u7528\u6ce8\u91ca\u8fdb\u884c\u6807\u8bc6 \u5f02\u6b65\u6267\u884c\u7684\u65b9\u6cd5\u3002\u5f53\u60a8\u6307\u5b9a \u65f6\uff0c\u8be5\u65b9\u6cd5\u5c06\u5728 Salesforce \u5177\u6709 \u53ef\u7528\u8d44\u6e90\u3002<samp>Future<\/samp><samp>Future<\/samp><\/p>\n\n\n\n<p>\u4f8b\u5982\uff0c\u60a8\u53ef\u4ee5\u5728\u4ee5\u4e0b\u60c5\u51b5\u4e0b\u4f7f\u7528\u6ce8\u91ca \u5bf9\u5916\u90e8\u670d\u52a1\u8fdb\u884c\u5f02\u6b65 Web \u670d\u52a1\u6807\u6ce8\u3002\u6ca1\u6709 \u6ce8\u89e3\u65f6\uff0cWeb \u670d\u52a1\u6807\u6ce8\u662f\u7531\u6267\u884c Apex \u4ee3\u7801\uff0c\u5728\u6807\u6ce8\u5b8c\u6210\u4e4b\u524d\uff0c\u4e0d\u80fd\u8fdb\u884c\u5176\u4ed6\u5904\u7406 \uff08\u540c\u6b65\u5904\u7406\uff09\u3002<samp>Future<\/samp><\/p>\n\n\n\n<p id=\"FutureMethodsRules\"><a><\/a>\u5e26\u6709\u6ce8\u89e3\u7684\u65b9\u6cd5\u5fc5\u987b\u662f\u9759\u6001\u65b9\u6cd5\uff0c\u5e76\u4e14\u53ea\u80fd\u8fd4\u56de void \u7c7b\u578b\u3002\u6307\u5b9a\u7684 \u53c2\u6570\u5fc5\u987b\u662f\u57fa\u5143\u6570\u636e\u7c7b\u578b\u3001\u57fa\u5143\u6570\u636e\u7c7b\u578b\u7684\u6570\u7ec4\u6216\u96c6\u5408 \u7684\u539f\u59cb\u6570\u636e\u7c7b\u578b\u3002\u5e26\u6709\u6ce8\u89e3\u7684\u65b9\u6cd5\u4e0d\u80fd\u5c06 sObjects \u6216\u5bf9\u8c61\u4f5c\u4e3a\u53c2\u6570\u3002<samp>Future<\/samp><samp>Future<\/samp><\/p>\n\n\n\n<p>\u82e5\u8981\u4f7f\u7c7b\u4e2d\u7684\u65b9\u6cd5\u5f02\u6b65\u6267\u884c\uff0c\u8bf7\u4f7f\u7528\u6ce8\u91ca\u5b9a\u4e49\u65b9\u6cd5\u3002\u4f8b\u5982\uff1a<samp>Future<\/samp><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>global class MyFutureClass {\n\n  @Future \n  static void myMethod(String a, Integer i) {\n    System.debug('Method called with: ' + a + ' and ' + i);\n    \/\/ Perform long-running code\n  }\n}<\/code><\/pre>\n\n\n\n<p>\u82e5\u8981\u5141\u8bb8\u5728\u65b9\u6cd5\u4e2d\u4f7f\u7528\u6807\u6ce8\uff0c\u8bf7\u6307\u5b9a \u3002\u9ed8\u8ba4\u503c\u4e3a \uff0c\u8fd9\u4f1a\u963b\u6b62\u65b9\u6cd5 \u8fdb\u884c\u6807\u6ce8\u3002<samp>Future<\/samp><samp>(callout=true)<\/samp><samp>(callout=false)<\/samp><\/p>\n\n\n\n<p>\u4ee5\u4e0b\u4ee3\u7801\u7247\u6bb5\u6f14\u793a\u5982\u4f55\u6307\u5b9a\u65b9\u6cd5\u6267\u884c \u6807\u6ce8\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>@Future (callout=true)\n  public static void doCalloutFromFuture() {\n   \/\/Add code to perform callout\n}<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">\u672a\u6765\u65b9\u6cd5\u6ce8\u610f\u4e8b\u9879<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u8bf7\u8bb0\u4f4f\uff0c\u4efb\u4f55\u4f7f\u7528\u6ce8\u89e3\u7684\u65b9\u6cd5\u90fd\u9700\u8981\u7279\u522b\u8003\u8651\uff0c\u56e0\u4e3a\u8be5\u65b9\u6cd5\u4e0d\u4e00\u5b9a \u6309\u8c03\u7528\u7684\u76f8\u540c\u987a\u5e8f\u6267\u884c\u3002<samp>Future<\/samp><\/li>\n\n\n\n<li><a><\/a>\u5e26\u6709\u6ce8\u91ca\u7684\u65b9\u6cd5\u4e0d\u80fd\u5728 Visualforce \u63a7\u5236\u5668\u4e2d\u4f7f\u7528 \u8981\u4e48\u662f\u65b9\u6cd5\uff0c\u8981\u4e48\u5728\u6784\u9020\u51fd\u6570\u4e2d\u3002<samp>Future<\/samp><samp>get<var>MethodName<\/var><\/samp><samp>set<var>MethodName<\/var><\/samp><\/li>\n\n\n\n<li>\u4e0d\u80fd\u4ece\u540c\u6837\u5177\u6709\u6279\u6ce8\u7684\u65b9\u6cd5\u8c03\u7528\u6279\u6ce8\u7684\u65b9\u6cd5\u3002\u4e5f\u4e0d\u80fd\u4ece\u8c03\u7528 \u53e6\u4e00\u4e2a\u5e26\u6ce8\u91ca\u7684\u65b9\u6cd5\u3002<samp>Future<\/samp><samp>Future<\/samp><\/li>\n<\/ul>\n\n\n\n<h1 class=\"wp-block-heading\">InvocableMethod\u6ce8\u89e3<\/h1>\n\n\n\n<p><a><\/a>\u4f7f\u7528\u6ce8\u91ca\u6765\u6807\u8bc6\u53ef\u4ee5\u4f5c\u4e3a\u53ef\u8c03\u7528\u8fd0\u884c\u7684\u65b9\u6cd5 \u884c\u52a8\u3002<samp>InvocableMethod<\/samp><\/p>\n\n\n\n<p>\u6ce8\u610f<\/p>\n\n\n\n<p>\u5982\u679c\u6d41\u8c03\u7528 Apex\uff0c\u5219\u6b63\u5728\u8fd0\u884c\u7684\u7528\u6237\u5fc5\u987b\u5177\u6709\u76f8\u5e94\u7684 Apex \u7c7b\u5b89\u5168\u6027 \u5728\u5176\u7528\u6237\u914d\u7f6e\u6587\u4ef6\u6216\u6743\u9650\u96c6\u4e2d\u8bbe\u7f6e\u3002<\/p>\n\n\n\n<p>\u53ef\u8c03\u7528\u65b9\u6cd5\u4ece\u4ea4\u4e92\u7684 Rest\u3001Apex\u3001Flow \u6216 Einstein \u673a\u5668\u4eba\u4e2d\u672c\u673a\u8c03\u7528 \u4e0e\u5916\u90e8 API \u6e90\u4e00\u8d77\u4f7f\u7528\u3002\u53ef\u8c03\u7528\u65b9\u6cd5\u5177\u6709\u52a8\u6001\u8f93\u5165\u548c\u8f93\u51fa\u503c\uff0c\u5e76\u4e14 \u652f\u6301\u63cf\u8ff0\u8c03\u7528\u3002<\/p>\n\n\n\n<p>\u6b64\u4ee3\u7801\u793a\u4f8b\u6f14\u793a\u5177\u6709\u57fa\u5143\u6570\u636e\u7c7b\u578b\u7684\u53ef\u8c03\u7528\u65b9\u6cd5\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>public class AccountQueryAction {\n  @InvocableMethod(label='Get Account Names' description='Returns the list of account names corresponding to the specified account IDs.' category='Account')\n  public static List&lt;String&gt; getAccountNames(List&lt;ID&gt; ids) {\n    List&lt;Account&gt; accounts = &#91;SELECT Name FROM Account WHERE Id in :ids];\n    Map&lt;ID, String&gt; idToName = new Map&lt;ID, String&gt;();\n    for (Account account : accounts) {\n      idToName.put(account.Id, account.Name);\n    }\n    \/\/ put each name in the output at the same position as the id in the input\n    List&lt;String&gt; accountNames = new List&lt;String&gt;();\n    for (String id : ids) {\n      accountNames.add(idToName.get(id));\n    }\n    return accountNames;\n  }\n}<\/code><\/pre>\n\n\n\n<p>\u6b64\u4ee3\u7801\u793a\u4f8b\u6f14\u793a\u5177\u6709\u7279\u5b9a sObject \u6570\u636e\u7c7b\u578b\u7684\u53ef\u8c03\u7528\u65b9\u6cd5\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>public class AccountInsertAction {\n  @InvocableMethod(label='Insert Accounts' description='Inserts the accounts specified and returns the IDs of the new accounts.' category= 'Account')\n  public static List&lt;ID&gt; insertAccounts(List&lt;Account&gt; accounts) {\n    Database.SaveResult&#91;] results = Database.insert(accounts);\n    List&lt;ID&gt; accountIds = new List&lt;ID&gt;();\n      for (Database.SaveResult result : results) {\n      accountIds.add(result.getId());\n    }\n    return accountIds;\n  }\n}<\/code><\/pre>\n\n\n\n<p>\u6b64\u4ee3\u7801\u793a\u4f8b\u6f14\u793a\u5177\u6709\u6cdb\u578b sObject \u6570\u636e\u7c7b\u578b\u7684\u53ef\u8c03\u7528\u65b9\u6cd5\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>public with sharing class GetFirstFromCollection {\n  @InvocableMethod\n  public static List&lt;Results&gt; execute (List&lt;Requests&gt; requestList) {\n    List&lt;Results&gt; results = new List&lt;Results&gt;();\n    for (Requests request : requestList) {\n      List&lt;SObject&gt; inputCollection = request.inputCollection;\n      SObject outputMember = inputCollection&#91;0];\n      \n      \/\/Create a Results object to hold the return values\n      Results result = new Results();\n      \n      \/\/Add the return values to the Results object\n      result.outputMember = outputMember;\n      \n      \/\/Add Result to the results List at the same position as the request is in the requests List\n      results.add(result);\n    }\n    return results;\n  }\n\n  public class Requests {\n    @InvocableVariable(label='Records for Input' description='yourDescription' required=true)\n    public List&lt;SObject&gt; inputCollection;\n  }\n\n  public class Results {\n    @InvocableVariable(label='Records for Output' description='yourDescription' required=true)\n    public SObject outputMember;\n  }\n}<\/code><\/pre>\n\n\n\n<p>\u6b64\u4ee3\u7801\u793a\u4f8b\u6f14\u793a\u4e86\u5177\u6709 SVG \u6587\u4ef6\u4e2d\u81ea\u5b9a\u4e49\u56fe\u6807\u7684\u53ef\u8c03\u7528\u65b9\u6cd5\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>global class CustomSvgIcon { \n  @InvocableMethod(label='myIcon' iconName='resource:myPackageNamespace__google:top')\n  global static List&lt;Integer&gt; myMethod(List&lt;Integer&gt; request) {\n    List&lt;Integer&gt; results = new List&lt;Integer&gt;();\n    for(Integer reqInt : request) { \n       results.add(reqInt);\n    }\n    return results;\n  }\n}<\/code><\/pre>\n\n\n\n<p>\u6b64\u4ee3\u7801\u793a\u4f8b\u663e\u793a\u4e86\u4e00\u4e2a\u5e26\u6709 Salesforce Lightning \u81ea\u5b9a\u4e49\u56fe\u6807\u7684\u53ef\u8c03\u7528\u65b9\u6cd5 \u8bbe\u8ba1\u7cfb\u7edf\uff08SLDS\uff09\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>public class CustomSldsIcon { \n  \n  @InvocableMethod(iconName='slds:standard:choice') \n  public static void run() {} \n  \n  }<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">\u652f\u6301\u7684\u4fee\u9970\u7b26<\/h2>\n\n\n\n<p>\u6240\u6709\u4fee\u9970\u7b26\u90fd\u662f\u53ef\u9009\u7684\u3002\u6807\u7b7e\u65b9\u6cd5\u7684\u6807\u7b7e\uff0c\u5728\u6d41\u751f\u6210\u5668\u4e2d\u663e\u793a\u4e3a\u64cd\u4f5c\u540d\u79f0\u3002\u8fd9 \u9ed8\u8ba4\u503c\u662f\u65b9\u6cd5\u540d\u79f0\uff0c\u4f46\u6211\u4eec\u5efa\u8bae\u60a8\u63d0\u4f9b\u6807\u7b7e\u3002\u63cf\u8ff0\u65b9\u6cd5\u7684\u8bf4\u660e\uff0c\u5728\u6d41\u4e2d\u663e\u793a\u4e3a\u64cd\u4f5c\u8bf4\u660e \u5efa\u7b51\u5de5\u4eba\u3002\u7f3a\u7701\u503c\u4e3a \u3002<samp>Null<\/samp>\u6807\u6ce8\u6807\u6ce8\u4fee\u9970\u7b26\u6807\u8bc6\u8be5\u65b9\u6cd5\u662f\u5426\u8c03\u7528\u5916\u90e8\u7cfb\u7edf\u3002\u5982\u679c \u8be5\u65b9\u6cd5\u8c03\u7528\u5916\u90e8\u7cfb\u7edf\uff0c\u6dfb\u52a0 .\u7f3a\u7701\u503c\u4e3a \u3002<samp>callout=true<\/samp><samp>false<\/samp>\u7c7b\u522b\u65b9\u6cd5\u7684\u7c7b\u522b\uff0c\u5728 Flow Builder \u4e2d\u663e\u793a\u4e3a\u64cd\u4f5c\u7c7b\u522b\u3002 \u5982\u679c\u672a\u63d0\u4f9b\u7c7b\u522b\uff08\u9ed8\u8ba4\u60c5\u51b5\u4e0b\uff09\uff0c\u5219\u64cd\u4f5c\u5c06\u663e\u793a\u5728\u201c\u672a\u5206\u7c7b\u201d\u4e0b\u3002\u914d\u7f6e\u7f16\u8f91\u5668\u4f7f\u7528\u65b9\u6cd5\u6ce8\u518c\u5e76\u663e\u793a\u5728 Flow \u4e2d\u7684\u81ea\u5b9a\u4e49\u5c5e\u6027\u7f16\u8f91\u5668 \u7ba1\u7406\u5458\u914d\u7f6e\u64cd\u4f5c\u65f6\u7684\u751f\u6210\u5668\u3002\u5982\u679c\u672a\u6307\u5b9a\u6b64\u4fee\u9970\u7b26\uff0c\u5219 Flow \u751f\u6210\u5668\u4f7f\u7528\u6807\u51c6\u5c5e\u6027\u7f16\u8f91\u5668\u3002\u56fe\u6807\u540d\u79f0\u8981\u7528\u4f5c Flow Builder \u4e2d\u64cd\u4f5c\u7684\u81ea\u5b9a\u4e49\u56fe\u6807\u7684\u56fe\u6807\u7684\u540d\u79f0 \u5e06\u5e03\u3002\u60a8\u53ef\u4ee5\u5c06\u4e0a\u4f20\u7684 SVG \u6587\u4ef6\u6307\u5b9a\u4e3a\u9759\u6001\u8d44\u6e90\uff0c\u4e5f\u53ef\u4ee5\u5c06 Salesforce Lightning Design System \u6807\u51c6\u56fe\u6807\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">InvocableMethod \u6ce8\u610f\u4e8b\u9879<\/h2>\n\n\n\n<p>\u5b9e\u65bd\u8bf4\u660e<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u53ef\u8c03\u7528\u65b9\u6cd5\u5fc5\u987b\u662f and \u6216 \uff0c\u5e76\u4e14\u5176\u7c7b\u5fc5\u987b\u662f\u5916\u90e8\u7c7b\u3002<samp>static<\/samp><samp>public<\/samp><samp>global<\/samp><\/li>\n\n\n\n<li>\u4e00\u4e2a\u7c7b\u4e2d\u53ea\u6709\u4e00\u4e2a\u65b9\u6cd5\u53ef\u4ee5\u5177\u6709\u6ce8\u91ca\u3002<samp>InvocableMethod<\/samp><\/li>\n\n\n\n<li>\u5176\u4ed6\u6279\u6ce8\u4e0d\u80fd\u4e0e\u6279\u6ce8\u4e00\u8d77\u4f7f\u7528\u3002<samp>InvocableMethod<\/samp><\/li>\n<\/ul>\n\n\n\n<p>\u8f93\u5165\u548c\u8f93\u51fa\u6700\u591a\u53ef\u4ee5\u6709\u4e00\u4e2a\u8f93\u5165\u53c2\u6570\uff0c\u5176\u6570\u636e\u7c7b\u578b\u5fc5\u987b\u4e3a\u4ee5\u4e0b\u53c2\u6570\u4e4b\u4e00\uff1a<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u57fa\u5143\u6570\u636e\u7c7b\u578b\u7684\u5217\u8868\u6216\u57fa\u5143\u6570\u636e\u7c7b\u578b\u7684\u5217\u8868\u5217\u8868 \u2013 \u6cdb\u578b\u7c7b\u578b\u4e0d\u662f \u652f\u6301\u3002<samp>Object<\/samp><\/li>\n\n\n\n<li>sObject \u7c7b\u578b\u7684\u5217\u8868\u6216 sObject \u7c7b\u578b\u7684\u5217\u8868\u5217\u8868\u3002<\/li>\n\n\n\n<li>\u6cdb\u578b sObject \u7c7b\u578b \uff08\uff09 \u7684\u5217\u8868\u6216\u6cdb\u578b sObject \u7c7b\u578b\u7684\u5217\u8868 ().<samp>List&lt;sObject&gt;<\/samp><samp>List&lt;List&lt;sObject&gt;&gt;<\/samp><\/li>\n\n\n\n<li>\u7528\u6237\u5b9a\u4e49\u7c7b\u578b\u7684\u5217\u8868\uff0c\u5305\u542b\u53d7\u652f\u6301\u7c7b\u578b\u7684\u53d8\u91cf\u6216 \u7528\u6237\u5b9a\u4e49\u7684 Apex \u7c7b\u578b\uff0c\u5e26\u6709\u6ce8\u91ca\u3002\u8981\u5b9e\u73b0\u60a8\u7684\u6570\u636e\u7c7b\u578b\uff0c\u8bf7\u521b\u5efa\u4e00\u4e2a \u81ea\u5b9a\u4e49\u5168\u5c40\u6216\u516c\u5171 Apex \u7c7b\u3002\u8be5\u7c7b\u5fc5\u987b\u5305\u542b\u81f3\u5c11\u4e00\u4e2a\u6210\u5458 \u53d8\u91cf\uff0c\u5e26\u6709\u53ef\u8c03\u7528\u7684\u53d8\u91cf\u6ce8\u89e3\u3002<samp>InvocableVariable<\/samp><\/li>\n<\/ul>\n\n\n\n<p>\u5982\u679c\u8fd4\u56de\u7c7b\u578b\u4e0d\u662f \uff0c\u5219\u6570\u636e \u65b9\u6cd5\u8fd4\u56de\u7684\u7c7b\u578b\u5fc5\u987b\u662f\u4e0b\u5217\u7c7b\u578b\u4e4b\u4e00\uff1a<samp>Null<\/samp><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u57fa\u5143\u6570\u636e\u7c7b\u578b\u7684\u5217\u8868\u6216\u57fa\u5143\u6570\u636e\u7c7b\u578b\u7684\u5217\u8868\u5217\u8868 \u2013 \u6cdb\u578b\u7c7b\u578b\u4e0d\u662f \u652f\u6301\u3002<samp>Object<\/samp><\/li>\n\n\n\n<li>sObject \u7c7b\u578b\u7684\u5217\u8868\u6216 sObject \u7c7b\u578b\u7684\u5217\u8868\u5217\u8868\u3002<\/li>\n\n\n\n<li>\u6cdb\u578b sObject \u7c7b\u578b \uff08\uff09 \u7684\u5217\u8868\u6216\u6cdb\u578b sObject \u7c7b\u578b\u7684\u5217\u8868 ().<samp>List&lt;sObject&gt;<\/samp><samp>List&lt;List&lt;sObject&gt;&gt;<\/samp><\/li>\n\n\n\n<li>\u7528\u6237\u5b9a\u4e49\u7c7b\u578b\u7684\u5217\u8868\uff0c\u5305\u542b\u53d7\u652f\u6301\u7c7b\u578b\u7684\u53d8\u91cf\u6216 \u7528\u6237\u5b9a\u4e49\u7684 Apex \u7c7b\u578b\uff0c\u5e26\u6709\u6ce8\u91ca\u3002\u8981\u5b9e\u73b0\u60a8\u7684\u6570\u636e\u7c7b\u578b\uff0c\u8bf7\u521b\u5efa\u4e00\u4e2a \u81ea\u5b9a\u4e49\u5168\u5c40\u6216\u516c\u5171 Apex \u7c7b\u3002\u8be5\u7c7b\u5fc5\u987b\u5305\u542b\u81f3\u5c11\u4e00\u4e2a\u6210\u5458 \u53d8\u91cf\uff0c\u5e26\u6709\u53ef\u8c03\u7528\u7684\u53d8\u91cf\u6ce8\u89e3\u3002<samp>InvocableVariable<\/samp>\u6ce8\u610f\u4e3a\u4e86\u6b63\u786e\u7684\u81a8\u80c0 \u5b9e\u73b0\u65f6\uff0c\u8f93\u5165\u548c\u8f93\u51fa\u7684\u5927\u5c0f\u548c\u987a\u5e8f\u5fc5\u987b\u5339\u914d\u3002 \u4f8b\u5982\uff0c\u7b2c i \u4e2a\u201c\u8f93\u51fa\u201d\u6761\u76ee\u5fc5\u987b\u4e0e\u7b2c i \u4e2a\u201c\u8f93\u5165\u201d\u6761\u76ee\u76f8\u5bf9\u5e94\u3002 \u5f53\u60a8\u7684\u64cd\u4f5c\u5728 \u6279\u91cf\u6267\u884c\uff0c\u4f8b\u5982\u5728\u8bb0\u5f55\u89e6\u53d1\u5668\u4e2d\u4f7f\u7528 Apex \u64cd\u4f5c\u65f6 \u6d41\u3002<\/li>\n<\/ul>\n\n\n\n<p>\u6258\u7ba1\u8f6f\u4ef6\u5305<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u53ef\u4ee5\u5728\u5305\u4e2d\u4f7f\u7528\u53ef\u8c03\u7528\u65b9\u6cd5\uff0c\u4f46\u5728\u6dfb\u52a0\u53ef\u8c03\u7528\u65b9\u6cd5\u540e \u65e0\u6cd5\u5c06\u5176\u4ece\u66f4\u9ad8\u7248\u672c\u7684\u5305\u4e2d\u5220\u9664\u3002<\/li>\n\n\n\n<li>\u516c\u5171\u53ef\u8c03\u7528\u65b9\u6cd5\u53ef\u7531 \u6258\u7ba1\u5305\u3002<\/li>\n\n\n\n<li>\u5168\u5c40\u53ef\u8c03\u7528\u65b9\u6cd5\u53ef\u4ee5\u5728\u8ba2\u9605\u8005\u7ec4\u7ec7\u4e2d\u7684\u4efb\u4f55\u4f4d\u7f6e\u5f15\u7528\u3002\u53ea \u5168\u5c40\u53ef\u8c03\u7528\u65b9\u6cd5\u663e\u793a\u5728 Flow Builder \u548c Process Builder \u7684 \u8ba2\u9605\u8005\u7ec4\u7ec7\u3002<\/li>\n<\/ul>\n\n\n\n<p>\u6709\u5173\u53ef\u8c03\u7528\u64cd\u4f5c\u7684\u8be6\u7ec6\u4fe1\u606f\uff0c\u8bf7\u53c2\u9605\u64cd\u4f5c\u5f00\u53d1\u4eba\u5458\u6307\u5357\u3002<\/p>\n\n\n\n<h1 class=\"wp-block-heading\">Invocable\u53d8\u91cf\u6ce8\u89e3<\/h1>\n\n\n\n<p><a><\/a>\u4f7f\u7528\u6ce8\u91ca\u6765\u6807\u8bc6 \u81ea\u5b9a\u4e49\u7c7b\u3002<samp>InvocableVariable<\/samp><\/p>\n\n\n\n<p>\u6ce8\u91ca\u6807\u8bc6\u7c7b \u53d8\u91cf\uff0c\u7528\u4f5c\u65b9\u6cd5\u7684\u53ef\u8c03\u7528\u64cd\u4f5c\u7684\u8f93\u5165\u6216\u8f93\u51fa\u53c2\u6570\u3002\u5982\u679c\u521b\u5efa\u81ea\u5df1\u7684\u81ea\u5b9a\u4e49\u7c7b\u4ee5 \u7528\u4f5c\u53ef\u8c03\u7528\u65b9\u6cd5\u7684\u8f93\u5165\u6216\u8f93\u51fa\uff0c\u53ef\u4ee5\u5bf9\u5355\u4e2a\u7c7b\u6210\u5458\u8fdb\u884c\u6ce8\u91ca \u53d8\u91cf\uff0c\u4f7f\u5b83\u4eec\u53ef\u4f9b\u65b9\u6cd5\u4f7f\u7528\u3002<samp>InvocableVariable<\/samp><samp>InvocableMethod<\/samp><\/p>\n\n\n\n<p>\u4e0b\u9762\u7684\u4ee3\u7801\u793a\u4f8b\u6f14\u793a\u4e86\u5177\u6709 invocable \u53d8\u91cf\u7684 invocable \u65b9\u6cd5\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>global class ConvertLeadAction {\n  @InvocableMethod(label='Convert Leads')\n  global static List&lt;ConvertLeadActionResult&gt; convertLeads(List&lt;ConvertLeadActionRequest&gt; requests) {\n    List&lt;ConvertLeadActionResult&gt; results = new List&lt;ConvertLeadActionResult&gt;();\n    for (ConvertLeadActionRequest request : requests) {\n      results.add(convertLead(request));\n    }\n    return results;\n  }\n\n  public static ConvertLeadActionResult convertLead(ConvertLeadActionRequest request) {\n    Database.LeadConvert lc = new Database.LeadConvert();\n    lc.setLeadId(request.leadId);\n    lc.setConvertedStatus(request.convertedStatus);\n\n    if (request.accountId != null) {\n        lc.setAccountId(request.accountId);\n    }\n\n    if (request.contactId != null) {\n      lc.setContactId(request.contactId);\n    }\n\n    if (request.overWriteLeadSource != null &amp;&amp; request.overWriteLeadSource) {\n      lc.setOverwriteLeadSource(request.overWriteLeadSource);\n    }\n\n    if (request.createOpportunity != null &amp;&amp; !request.createOpportunity) {\n      lc.setDoNotCreateOpportunity(!request.createOpportunity);\n    }\n\n    if (request.opportunityName != null) {\n      lc.setOpportunityName(request.opportunityName);\n    }\n\n    if (request.ownerId != null) {\n      lc.setOwnerId(request.ownerId);\n    }\n\n    if (request.sendEmailToOwner != null &amp;&amp; request.sendEmailToOwner) {\n      lc.setSendNotificationEmail(request.sendEmailToOwner);\n    }\n\n    Database.LeadConvertResult lcr = Database.convertLead(lc, true);\n    if (lcr.isSuccess()) {\n      ConvertLeadActionResult result = new ConvertLeadActionResult();\n      result.accountId = lcr.getAccountId();\n      result.contactId = lcr.getContactId();\n      result.opportunityId = lcr.getOpportunityId();\n      return result;\n    } else {\n      throw new ConvertLeadActionException(lcr.getErrors()&#91;0].getMessage());\n    }\n  }\n\n  global class ConvertLeadActionRequest {\n    @InvocableVariable(required=true)\n    global ID leadId;\n\n    @InvocableVariable(required=true)\n    global String convertedStatus;\n\n    @InvocableVariable\n    global ID accountId;\n\n    @InvocableVariable\n    global ID contactId;\n\n    @InvocableVariable\n    global Boolean overWriteLeadSource;\n\n    @InvocableVariable\n    global Boolean createOpportunity;\n\n    @InvocableVariable\n    global String opportunityName;\n\n    @InvocableVariable\n    global ID ownerId;\n\n    @InvocableVariable\n    global Boolean sendEmailToOwner;\n  }\n\n  global class ConvertLeadActionResult {\n    @InvocableVariable\n    global ID accountId;\n\n    @InvocableVariable\n    global ID contactId;\n\n    @InvocableVariable\n    global ID opportunityId;\n  }\n\n  class ConvertLeadActionException extends Exception {}\n}<\/code><\/pre>\n\n\n\n<p>\u4ee5\u4e0b\u4ee3\u7801\u793a\u4f8b\u6f14\u793a\u4e86\u4e00\u4e2a invocable \u65b9\u6cd5\uff0c\u8be5\u65b9\u6cd5\u5177\u6709 \u6cdb\u578b sObject \u6570\u636e\u7c7b\u578b\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>public with sharing class GetFirstFromCollection {\n  @InvocableMethod\n  public static List &lt;Results&gt; execute (List&lt;Requests&gt; requestList) {\n    List&lt;SObject&gt; inputCollection = requestList&#91;0].inputCollection;\n    SObject outputMember = inputCollection&#91;0];\n\n    \/\/Create a Results object to hold the return values\n    Results response = new Results();\n\n    \/\/Add the return values to the Results object\n    response.outputMember = outputMember;\n\n    \/\/Wrap the Results object in a List container \n    \/\/(an extra step added to allow this interface to also support bulkification)\n    List&lt;Results&gt; responseWrapper= new List&lt;Results&gt;();\n    responseWrapper.add(response);\n    return responseWrapper;    \n  }\n}\n\npublic class Requests {\n  @InvocableVariable(label='<em>Records for Input<\/em>' description='<em>yourDescription<\/em>' required=true)\n  public List&lt;SObject&gt; inputCollection;\n  }\n\npublic class Results {\n  @InvocableVariable(label='<em>Records for Output<\/em>' description='<em>yourDescription<\/em>' required=true)\n  public SObject outputMember;\n  }\n}<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">\u652f\u6301\u7684\u4fee\u9970\u7b26<\/h2>\n\n\n\n<p>\u53ef\u8c03\u7528\u53d8\u91cf\u6ce8\u91ca\u652f\u6301\u6b64\u793a\u4f8b\u4e2d\u6240\u793a\u7684\u4fee\u9970\u7b26\u3002<\/p>\n\n\n\n<p><samp>@InvocableVariable(label=&#8217;<var>yourLabel<\/var>&#8216;&nbsp;description=&#8217;<var>yourDescription<\/var>&#8216; required=(true | false))<\/samp>\u6240\u6709\u4fee\u9970\u7b26\u90fd\u662f\u53ef\u9009\u7684\u3002\u6807\u7b7e\u53d8\u91cf\u7684\u6807\u7b7e\u3002\u9ed8\u8ba4\u503c\u4e3a\u53d8\u91cf\u540d\u79f0\u3002<\/p>\n\n\n\n<p>\u63d0\u793a<\/p>\n\n\n\n<p>\u6b64\u6807\u7b7e\u663e\u793a\u5728 Flow Builder \u4e2d Action \u5143\u7d20\u7684 Action \u5143\u7d20\u4e2d \u5bf9\u5e94\u4e8e\u53ef\u8c03\u7528\u7684\u65b9\u6cd5\u3002\u6b64\u6807\u7b7e\u53ef\u5e2e\u52a9\u7ba1\u7406\u5458\u4e86\u89e3\u5982\u4f55\u4f7f\u7528 \u6d41\u4e2d\u7684\u53d8\u91cf\u3002\u63cf\u8ff0\u53d8\u91cf\u7684\u8bf4\u660e\u3002\u7f3a\u7701\u503c\u4e3a \u3002<samp>Null<\/samp>\u5fc5\u586b\u6307\u5b9a\u53d8\u91cf\u662f\u5426\u4e3a\u5fc5\u9700\u53d8\u91cf\u3002\u5982\u679c\u672a\u6307\u5b9a\uff0c\u5219\u9ed8\u8ba4\u503c\u4e3a false\u3002 \u5bf9\u4e8e\u8f93\u51fa\u53d8\u91cf\uff0c\u5c06\u5ffd\u7565\u8be5\u503c\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">InvocableVariable \u6ce8\u610f\u4e8b\u9879<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u5176\u4ed6\u6279\u6ce8\u4e0d\u80fd\u4e0e\u6279\u6ce8\u4e00\u8d77\u4f7f\u7528\u3002<samp>InvocableVariable<\/samp><\/li>\n\n\n\n<li>\u53ea\u6709\u5168\u5c40\u53d8\u91cf\u548c\u516c\u5171\u53d8\u91cf\u624d\u80fd\u662f\u53ef\u8c03\u7528\u53d8\u91cf\u3002<\/li>\n\n\n\n<li>\u53ef\u8c03\u7528\u53d8\u91cf\u4e0d\u80fd\u662f\u4ee5\u4e0b\u53d8\u91cf\u4e4b\u4e00\uff1a\n<ul class=\"wp-block-list\">\n<li>\u975e\u6210\u5458\u53d8\u91cf\uff0c\u5982 a \u6216 \u53d8\u91cf\u3002<samp>static<\/samp><samp>local<\/samp><\/li>\n\n\n\n<li>\u5c5e\u6027\u3002<\/li>\n\n\n\n<li>\u4e00\u4e2a\u53d8\u91cf\u3002<samp>final<\/samp><\/li>\n\n\n\n<li><samp>Protected<\/samp>\u6216\u3002<samp>private<\/samp><\/li>\n<\/ul>\n<\/li>\n\n\n\n<li>\u53ef\u8c03\u7528\u53d8\u91cf\u7684\u6570\u636e\u7c7b\u578b\u5fc5\u987b\u4e3a\u4e0b\u5217\u7c7b\u578b\u4e4b\u4e00\uff1a\n<ul class=\"wp-block-list\">\n<li>Object \u4ee5\u5916\u7684\u57fa\u5143<\/li>\n\n\n\n<li>sObject\uff0c\u6cdb\u578b sObject \u6216\u7279\u5b9a sObject<\/li>\n\n\n\n<li>\u4ece Apex \u521b\u5efa\u7684\u57fa\u5143\u3001sObjects\u3001\u5bf9\u8c61\u5217\u8868\u7684\u5217\u8868\u6216\u5217\u8868 \u7c7b\u6216\u96c6\u5408<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li>Apex \u4e2d\u7684\u53ef\u8c03\u7528\u53d8\u91cf\u540d\u79f0\u5fc5\u987b\u4e0e\u6d41\u7a0b\u4e2d\u7684\u540d\u79f0\u5339\u914d\u3002\u540d\u79f0\u533a\u5206\u5927\u5c0f\u5199\u3002<\/li>\n\n\n\n<li>\u5bf9\u4e8e\u6258\u7ba1\u8f6f\u4ef6\u5305\uff1a\n<ul class=\"wp-block-list\">\n<li>\u516c\u5171\u53ef\u8c03\u7528\u53d8\u91cf\u53ef\u4ee5\u5728\u540c\u4e00\u6258\u7ba1\u7684\u6d41\u548c\u6d41\u7a0b\u4e2d\u8bbe\u7f6e \u5305\u3002<\/li>\n\n\n\n<li>\u5168\u5c40\u53ef\u8c03\u7528\u53d8\u91cf\u53ef\u4ee5\u5728\u8ba2\u9605\u8005\u7ec4\u7ec7\u4e2d\u7684\u4efb\u4f55\u4f4d\u7f6e\u8bbe\u7f6e\u3002\u53ea\u6709\u5168\u7403 \u53ef\u8c03\u7528\u53d8\u91cf\u663e\u793a\u5728\u8ba2\u9605\u8005\u7684 Flow Builder \u548c Process Builder \u4e2d \u7ec4\u7ec7\u3002<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n\n\n\n<h1 class=\"wp-block-heading\">IsTest\u7684\u6ce8\u89e3<\/h1>\n\n\n\n<p id=\"isTest_defn\"><a><\/a>\u4f7f\u7528\u6ce8\u91ca \u5b9a\u4e49\u4ec5\u5305\u542b\u7528\u4e8e\u6d4b\u8bd5\u5e94\u7528\u7a0b\u5e8f\u7684\u4ee3\u7801\u7684\u7c7b\u548c\u65b9\u6cd5\u3002\u8fd9 \u6ce8\u91ca\u53ef\u4ee5\u5728\u62ec\u53f7\u5185\u4f7f\u7528\u591a\u4e2a\u4fee\u9970\u7b26\uff0c\u5e76\u7528\u7a7a\u683c\u5206\u9694\u3002<samp>@IsTest<\/samp><\/p>\n\n\n\n<p>\u6ce8\u610f<\/p>\n\n\n\n<p>\u4e0a\u7684\u6ce8\u91ca methods \u7b49\u540c\u4e8e\u5173\u952e\u5b57\u3002\u5982 \u6700\u4f73\u505a\u6cd5\uff0cSalesforce \u5efa\u8bae\u60a8\u4f7f\u7528 \u800c\u4e0d\u662f .\u5173\u952e\u5b57\u53ef\u4ee5\u5728 \u672a\u6765\u7248\u672c\u3002<samp>@IsTest<\/samp><samp>testMethod<\/samp><samp>@IsTest<\/samp><samp>testMethod<\/samp><samp>testMethod<\/samp><\/p>\n\n\n\n<p>\u7c7b\u548c\u65b9\u6cd5\u5b9a\u4e49\u4e3a can be \u6216 \u3002\u5b9a\u4e49\u4e3a\u7684\u7c7b\u5fc5\u987b\u662f\u9876\u7ea7\u7c7b\u3002<samp>@IsTest<\/samp><samp>private<\/samp><samp>public<\/samp><samp>@IsTest<\/samp><\/p>\n\n\n\n<p>\u6ce8\u610f<\/p>\n\n\n\n<p>\u4f7f\u7528\u6ce8\u91ca\u5b9a\u4e49\u7684\u7c7b\u4e0d\u8ba1\u5165\u7ec4\u7ec7 6 MB \u7684\u9650\u5236 \u6240\u6709 Apex \u4ee3\u7801\u3002<samp>@IsTest<\/samp><\/p>\n\n\n\n<p id=\"isTestExampleText\"><a><\/a>\u4e0b\u9762\u662f\u4e00\u4e2a\u5305\u542b\u4e24\u4e2a\u6d4b\u8bd5\u7684\u79c1\u6709\u6d4b\u8bd5\u7c7b\u7684\u793a\u4f8b \u65b9\u6cd5\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>@IsTest\nprivate class MyTestClass {\n\n   \/\/ Methods for testing\n   @IsTest\n   static void test1() {\n      \/\/ Implement test code\n   }\n\n   @IsTest\n   static void test2() {\n      \/\/ Implement test code\n   }\n\n}<\/code><\/pre>\n\n\n\n<p>\u4e0b\u9762\u662f\u5305\u542b\u5b9e\u7528\u7a0b\u5e8f\u7684\u516c\u5171\u6d4b\u8bd5\u7c7b\u7684\u793a\u4f8b \u6d4b\u8bd5\u6570\u636e\u7684\u65b9\u6cd5 \u521b\u9020\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>@IsTest \npublic class TestUtil {\n\n   public static void createTestAccounts() { \n      \/\/ Create some test accounts\n   }\n\n   public static void createTestContacts() {\n      \/\/ Create some test contacts\n   }\n\n}<\/code><\/pre>\n\n\n\n<p>\u5b9a\u4e49\u4e3a \u4e0d\u80fd\u662f\u63a5\u53e3\u6216 \u679a\u4e3e\u3002<samp>@IsTest<\/samp><\/p>\n\n\n\n<p>\u516c\u5171\u6d4b\u8bd5\u7c7b\u7684\u65b9\u6cd5\u53ea\u80fd\u4ece \u8fd0\u884c\u6d4b\u8bd5\uff0c\u5373\u6d4b\u8bd5\u65b9\u6cd5\u6216\u6d4b\u8bd5\u65b9\u6cd5\u8c03\u7528\u7684\u4ee3\u7801\u3002\u975e\u6d4b\u8bd5 \u8bf7\u6c42\u4e0d\u80fd\u8c03\u7528\u516c\u5171\u65b9\u6cd5\u3002.\u8981\u4e86\u89e3\u5404\u79cd\u65b9\u6cd5\uff0c\u8bf7\u6267\u884c\u4ee5\u4e0b\u64cd\u4f5c \u8fd0\u884c\u6d4b\u8bd5\u65b9\u6cd5\uff0c\u8bf7\u53c2\u9605\u8fd0\u884c\u5355\u5143\u6d4b\u8bd5\u65b9\u6cd5\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">@IsTest\uff08SeeAllData=true\uff09\u6ce8\u89e3<\/h2>\n\n\n\n<p>\u5bf9\u4e8e\u4f7f\u7528 Salesforce API \u7248\u672c 24.0 \u4fdd\u5b58\u7684 Apex \u4ee3\u7801 \u7a0d\u540e\uff0c\u4f7f\u7528\u6ce8\u89e3\u6388\u4e88\u6d4b\u8bd5\u7c7b\u548c \u5355\u4e2a\u6d4b\u8bd5\u65b9\u6cd5\u8bbf\u95ee\u7ec4\u7ec7\u4e2d\u7684\u6240\u6709\u6570\u636e\u3002\u4ea4\u901a \u5305\u62ec\u6d4b\u8bd5\u672a\u521b\u5efa\u7684\u9884\u5148\u5b58\u5728\u7684\u6570\u636e\u3002\u4ece Apex \u4ee3\u7801\u5f00\u59cb \u4f7f\u7528 Salesforce API \u7248\u672c 24.0 \u4fdd\u5b58\uff0c\u6d4b\u8bd5\u65b9\u6cd5\u65e0\u6743\u8bbf\u95ee \u7ec4\u7ec7\u4e2d\u9884\u5148\u5b58\u5728\u7684\u6570\u636e\u3002\u4f46\u662f\uff0c\u4fdd\u5b58\u7684\u6d4b\u8bd5\u4ee3\u7801 Salesforce API \u7248\u672c 23.0 \u53ca\u66f4\u65e9\u7248\u672c\u7ee7\u7eed\u53ef\u4ee5\u8bbf\u95ee \u7ec4\u7ec7\u3002<samp>@IsTest(SeeAllData=true)<\/samp>\u8bf7\u53c2\u89c1\u5728\u5355\u5143\u6d4b\u8bd5\u4e2d\u5c06\u6d4b\u8bd5\u6570\u636e\u4e0e\u7ec4\u7ec7\u6570\u636e\u9694\u79bb\u3002\u6ce8\u91ca\u7684\u6ce8\u610f\u4e8b\u9879<samp>@IsTest(SeeAllData=true)<\/samp><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u5982\u679c\u6d4b\u8bd5\u7c7b\u662f\u7528\u6ce8\u89e3\u5b9a\u4e49\u7684\uff0c\u5219 \u672a\u663e\u5f0f\u8bbe\u7f6e\u5173\u952e\u5b57\u7684\u6d4b\u8bd5\u65b9\u6cd5\u3002<samp>@IsTest(SeeAllData=true)<\/samp><samp>SeeAllData=true<\/samp><samp>SeeAllData<\/samp><\/li>\n\n\n\n<li>\u6ce8\u89e3\u7528\u4e8e\u6253\u5f00 \u5728\u7c7b\u6216\u65b9\u6cd5\u7ea7\u522b\u5e94\u7528\u65f6\u7684\u6570\u636e\u8bbf\u95ee\u3002\u4f46\u662f\uff0c\u5982\u679c \u5305\u542b\u7c7b\u5df2\u7528 \u3001 \u5bf9\u4e8e\u65b9\u6cd5\uff0c\u5c06\u5ffd\u7565\u5bf9\u65b9\u6cd5\u8fdb\u884c\u6279\u6ce8\u3002 \u5728\u8fd9\u79cd\u60c5\u51b5\u4e0b\uff0c\u8be5\u65b9\u6cd5\u4ecd\u7136\u53ef\u4ee5\u8bbf\u95ee \u7ec4\u7ec7\u3002\u4f7f\u7528\u91cd\u5199\u5bf9\u65b9\u6cd5\u8fdb\u884c\u6ce8\u91ca\uff0c\u5bf9\u4e8e\u8be5\u65b9\u6cd5\uff0c\u5bf9 \u7c7b\u3002<samp>@IsTest(SeeAllData=true)<\/samp><samp>@IsTest(SeeAllData=true)<\/samp><samp>@IsTest(SeeAllData=false)<\/samp><samp>@IsTest(SeeAllData=true)<\/samp><samp>@IsTest(SeeAllData=false)<\/samp><\/li>\n\n\n\n<li><samp>@IsTest(SeeAllData=true)<\/samp>\u5e76\u4e14\u4e0d\u80fd\u4f7f\u7528\u6ce8\u91ca \u4e00\u8d77\u4f7f\u7528\u76f8\u540c\u7684 Apex \u65b9\u6cd5\u3002<samp>@IsTest(IsParallel=true)<\/samp><\/li>\n<\/ul>\n\n\n\n<p>\u6b64\u793a\u4f8b\u6f14\u793a\u5982\u4f55\u4f7f\u7528\u6ce8\u91ca\u5b9a\u4e49\u6d4b\u8bd5\u7c7b\u3002\u6240\u6709 \u6b64\u7c7b\u4e2d\u7684\u6d4b\u8bd5\u65b9\u6cd5\u53ef\u4ee5\u8bbf\u95ee \u7ec4\u7ec7\u3002<\/p>\n\n\n\n<p><samp>@IsTest(SeeAllData=true)<\/samp><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\/\/ All test methods in this class can access all data.\n@IsTest(SeeAllData=true)\npublic class TestDataAccessClass {\n\n    \/\/ This test accesses an existing account. \n    \/\/ It also creates and accesses a new test account.\n    @IsTest\n    static void myTestMethod1() {\n        \/\/ Query an existing account in the organization. \n        Account a = &#91;SELECT Id, Name FROM Account WHERE Name='Acme' LIMIT 1];\n        System.assert(a != null);\n        \n        \/\/ Create a test account based on the queried account.\n        Account testAccount = a.clone();\n        testAccount.Name = 'Acme Test';\n        insert testAccount;\n        \n        \/\/ Query the test account that was inserted.\n        Account testAccount2 = &#91;SELECT Id, Name FROM Account \n                                WHERE Name='Acme Test' LIMIT 1];\n        System.assert(testAccount2 != null);\n    }\n       \n    \n    \/\/ Like the previous method, this test method can also access all data\n    \/\/ because the containing class is annotated with @IsTest(SeeAllData=true).\n    @IsTest\n    static void myTestMethod2() {\n        \/\/ Can access all data in the organization.\n   }\n  \n}<\/code><\/pre>\n\n\n\n<p>\u7b2c\u4e8c\u4e2a\u793a\u4f8b\u6f14\u793a\u5982\u4f55\u5728\u6d4b\u8bd5\u4e0a\u5e94\u7528\u6ce8\u91ca \u65b9\u6cd5\u3002\u7531\u4e8e\u6d4b\u8bd5\u65b9\u6cd5\u7684\u7c7b\u6ca1\u6709\u6ce8\u91ca\uff0c\u56e0\u6b64\u5fc5\u987b\u6ce8\u91ca \u65b9\u6cd5\uff0c\u4ee5\u4fbf\u80fd\u591f\u8bbf\u95ee\u8be5\u65b9\u6cd5\u7684\u6240\u6709\u6570\u636e\u3002\u7b2c\u4e8c\u79cd\u6d4b\u8bd5\u65b9\u6cd5\u6ca1\u6709 \u5177\u6709\u6b64\u6ce8\u91ca\uff0c\u56e0\u6b64\u5b83\u53ea\u80fd\u8bbf\u95ee\u5b83\u521b\u5efa\u7684\u6570\u636e\u3002\u6b64\u5916\uff0c\u5b83\u8fd8\u53ef\u4ee5 \u8bbf\u95ee\u7528\u4e8e\u7ba1\u7406\u7ec4\u7ec7\u7684\u5bf9\u8c61\uff0c\u4f8b\u5982 \u7528\u6237\u3002<\/p>\n\n\n\n<p><samp>@IsTest(SeeAllData=true)<\/samp><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\/\/ This class contains test methods with different data access levels.\n@IsTest\nprivate class ClassWithDifferentDataAccess {\n\n    \/\/ Test method that has access to all data.\n    @IsTest(SeeAllData=true)\n    static void testWithAllDataAccess() {\n        \/\/ Can query all data in the organization.      \n    }\n    \n    \/\/ Test method that has access to only the data it creates\n    \/\/ and organization setup and metadata objects.\n    @IsTest\n    static void testWithOwnDataAccess() {\n        \/\/ This method can still access the User object.\n        \/\/ This query returns the first user object.\n        User u = &#91;SELECT UserName,Email FROM User LIMIT 1]; \n        System.debug('UserName: ' + u.UserName);\n        System.debug('Email: ' + u.Email);\n        \n        \/\/ Can access the test account that is created here.\n        Account a = new Account(Name='Test Account');\n        insert a;      \n        \/\/ Access the account that was just created.\n        Account insertedAcct = &#91;SELECT Id,Name FROM Account \n                                WHERE Name='Test Account'];\n        System.assert(insertedAcct != null);\n    }\n}<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">@IsTest\uff08OnInstall=true\uff09\u6ce8\u89e3<\/h2>\n\n\n\n<p id=\"isTest_OnInstall_defn\"><a><\/a>\u4f7f\u7528\u6ce8\u91ca\u6307\u5b9a\u54ea\u4e9b Apex \u6d4b\u8bd5\u662f \u5728\u8f6f\u4ef6\u5305\u5b89\u88c5\u671f\u95f4\u6267\u884c\u3002\u6b64\u6ce8\u91ca\u7528\u4e8e\u6258\u7ba1\u4e2d\u7684\u6d4b\u8bd5 \u6216\u975e\u6258\u7ba1\u5305\u3002\u4ec5\u6d4b\u8bd5\u5177\u6709\u6b64\u6ce8\u91ca\u7684\u65b9\u6cd5\uff0c\u6216\u5177\u6709\u6b64\u6ce8\u91ca\u7684\u65b9\u6cd5 \u5177\u6709\u6b64\u6ce8\u91ca\u7684\u6d4b\u8bd5\u7c7b\u7684\u4e00\u90e8\u5206\u5728\u6253\u5305\u8fc7\u7a0b\u4e2d\u6267\u884c \u5b89\u88c5\u3002<samp>@IsTest(OnInstall=true)<\/samp><a><\/a>\u6ce8\u91ca\u4e3a\u5728\u6253\u5305\u671f\u95f4\u8fd0\u884c\u7684\u6d4b\u8bd5 \u5b89\u88c5\u5fc5\u987b\u901a\u8fc7\u624d\u80fd\u6210\u529f\u5b89\u88c5\u5305\u3002\u4e0d\u662f \u5728\u8f6f\u4ef6\u5305\u5b89\u88c5\u671f\u95f4\u7ed5\u8fc7\u5931\u8d25\u6d4b\u8bd5\u7684\u53ef\u80fd\u6027\u66f4\u957f\u3002<a><\/a>\u6ca1\u6709\u6b64\u6ce8\u91ca\u7684\u6d4b\u8bd5\u65b9\u6cd5\u6216\u7c7b\uff0c \u6216\u8005\uff0c\u5728\u5b89\u88c5\u8fc7\u7a0b\u4e2d\u4e0d\u4f1a\u6267\u884c\u5e26\u6709 \u6216 \u6ce8\u91ca\u7684\u3002<samp>@IsTest(OnInstall=false)<\/samp><samp>@IsTest<\/samp><\/p>\n\n\n\n<p>\u5728\u5305\u5b89\u88c5\u548c\u5347\u7ea7\u671f\u95f4\u8fd0\u884c\u7684\u5e26\u6279\u6ce8\u7684\u6d4b\u8bd5\u4e0d\u8ba1\u5165\u4ee3\u7801\u8986\u76d6\u7387\u3002 \u4f46\u662f\uff0c\u5728\u5305\u521b\u5efa\u64cd\u4f5c\u671f\u95f4\u4f1a\u8ddf\u8e2a\u548c\u8ba1\u7b97\u4ee3\u7801\u8986\u76d6\u7387\u3002 \u56e0\u4e3a\u4ece\u6258\u7ba1\u8f6f\u4ef6\u5305\u5b89\u88c5\u7684 Apex \u4ee3\u7801\u88ab\u6392\u9664\u5728\u7ec4\u7ec7\u7ea7\u522b\u4e4b\u5916 \u5bf9\u4ee3\u7801\u8986\u76d6\u7387\u7684\u8981\u6c42\uff0c\u60a8\u4e0d\u592a\u53ef\u80fd\u53d7\u5230\u5f71\u54cd\u3002\u4f46\u662f\uff0c\u5982\u679c\u4f60 \u8ddf\u8e2a\u6258\u7ba1\u5305\u6d4b\u8bd5\u8986\u76d6\u7387\uff0c\u5219\u5fc5\u987b\u5728 \u8981\u66f4\u65b0\u4ee3\u7801\u8986\u76d6\u7387\u7edf\u8ba1\u4fe1\u606f\u7684\u5305\u5b89\u88c5\u6216\u5347\u7ea7\u64cd\u4f5c\u3002 \u5305\u5b89\u88c5\u4e0d\u4f1a\u88ab\u4ee3\u7801\u8986\u76d6\u7387\u8981\u6c42\u963b\u6b62\u3002<samp>IsTest(OnInstall=true)<\/samp><\/p>\n\n\n\n<p id=\"OnInstallExample\"><a><\/a>\u6b64\u793a\u4f8b\u6f14\u793a\u5982\u4f55\u5bf9\u6d4b\u8bd5\u65b9\u6cd5\u8fdb\u884c\u6279\u6ce8\uff0c\u8be5\u65b9\u6cd5\u4e3a \u5728\u8f6f\u4ef6\u5305\u5b89\u88c5\u671f\u95f4\u6267\u884c\u3002\u5728\u6b64\u793a\u4f8b\u4e2d\uff0c\u5df2\u6267\u884c\uff0c\u4f46\u672a\u6267\u884c\u3002<samp>test1<\/samp><samp>test2<\/samp><samp>test3<\/samp><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>public class OnInstallClass {\n   \/\/ Implement logic for the class.\n   public void method1(){\n      \/\/ Some code\n   }\n}<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>@IsTest\nprivate class OnInstallClassTest {\n   \/\/ This test method will be executed\n   \/\/ during the installation of the package.\n   @IsTest(OnInstall=true)\n   static void test1() {\n      \/\/ Some test code\n   }\n\n   \/\/ Tests excluded from running during the\n   \/\/ the installation of a package.\n\n   @IsTest\n   static void test2() {\n      \/\/ Some test code\n   }\n\n   @IsTest\n   static void test3() {\n      \/\/ Some test code\n   }\n}<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">@IsTest\uff08IsParallel=true\uff09\u6ce8\u89e3<\/h2>\n\n\n\n<p><a><\/a>\u4f7f\u7528\u6ce8\u91ca\u6765\u6307\u793a\u6d4b\u8bd5\u7c7b \u53ef\u4ee5\u5e76\u884c\u8fd0\u884c\u3002\u5bf9\u5e76\u53d1\u6d4b\u8bd5\u6570\u7684\u9ed8\u8ba4\u9650\u5236\u6ca1\u6709 \u9002\u7528\u4e8e\u8fd9\u4e9b\u6d4b\u8bd5\u8bfe\u7a0b\u3002\u6b64\u6ce8\u89e3\u4f7f\u6d4b\u8bd5\u7c7b\u7684\u6267\u884c \u6548\u7387\u66f4\u9ad8\uff0c\u56e0\u4e3a\u53ef\u4ee5\u5e76\u884c\u8fd0\u884c\u66f4\u591a\u6d4b\u8bd5\u3002<samp>@IsTest(IsParallel=true)<\/samp><a><\/a>\u6ce8\u91ca\u7684\u6ce8\u610f\u4e8b\u9879<samp>@IsTest(IsParallel=true)<\/samp><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u6b64\u6ce8\u91ca\u5c06\u8986\u76d6\u7981\u7528\u5e76\u884c\u7684\u8bbe\u7f6e \u6d4b\u8bd5\u3002<\/li>\n\n\n\n<li><samp>@IsTest(SeeAllData=true)<\/samp>\u548c\u6ce8\u91ca\u4e0d\u80fd\u5728\u540c\u4e00\u4e2a Apex \u65b9\u6cd5\u4e0a\u4e00\u8d77\u4f7f\u7528\u3002<samp>@IsTest(IsParallel=true)<\/samp><\/li>\n<\/ul>\n\n\n\n<h1 class=\"wp-block-heading\">JsonAccess\u6ce8\u89e3<\/h1>\n\n\n\n<p>\u5728 Apex \u7c7b\u4e2d\u5b9a\u4e49\u7684\u6ce8\u91ca \u7ea7\u522b\u63a7\u5236\u7c7b\u7684\u5b9e\u4f8b\u662f\u5426\u53ef\u4ee5\u5e8f\u5217\u5316\u6216\u53cd\u5e8f\u5217\u5316\u3002\u5982\u679c \u6ce8\u89e3\u9650\u5236\u4e86 JSON \u5e8f\u5217\u5316\u548c\u53cd\u5e8f\u5217\u5316\uff0c\u629b\u51fa\u8fd0\u884c\u65f6\u5f02\u5e38\u3002<samp>@JsonAccess<\/samp><samp>JSONException<\/samp>\u6ce8\u89e3\u7684 \u548c \u53c2\u6570\u5f3a\u5236\u6267\u884c Apex \u5141\u8bb8\u5e8f\u5217\u5316\u548c \u53cd\u5e8f\u5217\u5316\u3002\u60a8\u53ef\u4ee5\u6307\u5b9a\u4e00\u4e2a\u6216\u4e24\u4e2a\u53c2\u6570\uff0c\u4f46\u4e0d\u80fd\u6307\u5b9a\u6ce8\u91ca \u6ca1\u6709\u53c2\u6570\u3002\u53c2\u6570\u7684\u6709\u6548\u503c\uff0c\u7528\u4e8e\u6307\u793a\u5e8f\u5217\u5316\u548c \u5141\u8bb8\u53cd\u5e8f\u5217\u5316\uff1a<\/p>\n\n\n\n<p><samp>serializable<\/samp><samp>deserializable<\/samp><samp>@JsonAccess<\/samp><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><samp>never<\/samp>\uff1a\u4ece\u4e0d\u5141\u8bb8<\/li>\n\n\n\n<li><samp>sameNamespace<\/samp>\uff1a\u4ec5\u5141\u8bb8 Apex \u4ee3\u7801 \u76f8\u540c\u7684\u547d\u540d\u7a7a\u95f4<\/li>\n\n\n\n<li><samp>samePackage<\/samp>\uff1a\u4ec5\u5141\u8bb8 Apex \u4ee3\u7801 \u76f8\u540c\u7684\u5305\uff08\u4ec5\u5f71\u54cd\u7b2c\u4e8c\u4ee3\u5305\uff09<\/li>\n\n\n\n<li><samp>always<\/samp>\uff1a\u59cb\u7ec8\u5141\u8bb8\u4efb\u4f55 Apex \u4ee3\u7801<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">JsonAccess\u8003\u8651<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u5982\u679c\u6ce8\u91ca\u4e3a \u6269\u5c55\u65f6\uff0c\u6269\u5c55\u7c7b\u4e0d\u7ee7\u627f\u6b64\u5c5e\u6027\u3002<samp>JsonAccess<\/samp><\/li>\n\n\n\n<li>\u5982\u679c\u5c06\u8be5\u65b9\u6cd5\u5e94\u7528\u4e8e\u5bf9\u8c61 \u8fd9\u4e0d\u80fd\u88ab\u5e8f\u5217\u5316\uff0c\u79c1\u4eba\u6570\u636e\u53ef\u4ee5\u88ab\u66b4\u9732\u3002\u60a8\u5fc5\u987b\u5728\u5fc5\u987b\u4fdd\u62a4\u5176\u6570\u636e\u7684\u5bf9\u8c61\u4e0a\u91cd\u5199\u8be5\u65b9\u6cd5\u3002 \u4f8b\u5982\uff0c\u5e8f\u5217\u5316\u5728 Map \u4e2d\u5b58\u50a8\u4e3a\u952e\u7684\u5bf9\u8c61\u4f1a\u8c03\u7528\u8be5\u65b9\u6cd5\u3002\u751f\u6210\u7684\u6620\u5c04\u5305\u62ec\u952e\uff08\u5b57\u7b26\u4e32\uff09 \u548c\u503c\u6761\u76ee\uff0c\u4ece\u800c\u516c\u5f00\u5bf9\u8c61\u7684\u6240\u6709\u5b57\u6bb5\u3002<samp>toString<\/samp><samp>toString<\/samp><samp>toString<\/samp><\/li>\n<\/ul>\n\n\n\n<p>\u6b64\u793a\u4f8b\u4ee3\u7801\u663e\u793a\u4e86\u4e00\u4e2a\u6807\u6709\u6ce8\u91ca\u7684 Apex \u7c7b\u3002<samp>@JsonAccess<\/samp><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\/\/ SomeSerializableClass is serializable in the same package and deserializable in the wider namespace\n\n@JsonAccess(serializable='samePackage' deserializable=\u2019sameNamespace\u2019)\npublic class SomeSerializableClass { }\n\n\n\/\/ AlwaysDeserializable class is always deserializable and serializable only in the same namespace (default value from version 49.0 onwards)\n\n@JsonAccess(deserializable=\u2019always\u2019)\npublic class AlwaysDeserializable { }<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">\u7248\u672c\u5316\u884c\u4e3a\u66f4\u6539<\/h2>\n\n\n\n<p>\u5728\u7248\u672c 48.0 \u53ca\u66f4\u65e9\u7248\u672c\u4e2d\uff0c\u53cd\u5e8f\u5217\u5316\u7684\u9ed8\u8ba4\u8bbf\u95ee\u6743\u9650\u662f\uff0c\u5e8f\u5217\u5316\u7684\u9ed8\u8ba4\u8bbf\u95ee\u6743\u9650\u662f\u4fdd\u7559\u73b0\u6709\u884c\u4e3a\u3002\u4ece \u4ece\u7248\u672c 49.0 \u5f00\u59cb\uff0c\u5e8f\u5217\u5316\u548c\u53cd\u5e8f\u5217\u5316\u7684\u9ed8\u8ba4\u8bbf\u95ee\u6743\u9650\u4e3a \u3002<samp>always<\/samp><samp>sameNamespace<\/samp><samp>sameNamespace<\/samp><\/p>\n\n\n\n<h1 class=\"wp-block-heading\">\u547d\u540d\u7a7a\u95f4\u53ef\u8bbf\u95ee\u6ce8\u89e3<\/h1>\n\n\n\n<p>\u5728 \u5305\u53ef\u7528\u4e8e\u4f7f\u7528\u76f8\u540c\u547d\u540d\u7a7a\u95f4\u7684\u5176\u4ed6\u5305\u3002\u6ca1\u6709\u8fd9\u4e2a \u6ce8\u89e3\u3001\u5b9a\u4e49\u7684 Apex \u7c7b\u3001\u65b9\u6cd5\u3001\u63a5\u53e3\u3001\u5c5e\u6027\u548c\u62bd\u8c61\u7c7b \u5728 2GP \u5305\u4e2d\uff0c\u65e0\u6cd5\u88ab\u4e0e\u5b83\u4eec\u5171\u4eab\u7684\u5176\u4ed6\u5305\u8bbf\u95ee \u547d\u540d\u7a7a\u95f4\u3002\u58f0\u660e\u4e3a\u5168\u5c40\u7684 Apex \u5728\u6240\u6709\u547d\u540d\u7a7a\u95f4\u4e2d\u59cb\u7ec8\u53ef\u7528\uff0c\u5e76\u4e14 \u4e0d\u9700\u8981\u6ce8\u91ca\u3002<samp>@NamespaceAccessible<\/samp><\/p>\n\n\n\n<p>\u6709\u5173 2GP \u6258\u7ba1\u5305\u7684\u8be6\u7ec6\u4fe1\u606f\uff0c\u8bf7\u53c2\u9605\u7b2c\u4e8c\u4ee3\u6258\u7ba1\u5305&nbsp;Salesforce DX \u5f00\u53d1\u4eba\u5458\u6307\u5357\u4e2d\u7684\u8f6f\u4ef6\u5305\u3002<\/p>\n\n\n\n<p>\u8de8 Apex \u53ef\u8bbf\u95ee\u6027\u7684\u6ce8\u610f\u4e8b\u9879 \u5305<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u4e0d\u80fd\u5c06\u6ce8\u91ca\u7528\u4e8e Apex \u65b9\u6cd5\u3002<samp>@NamespaceAccessible<\/samp><samp>@AuraEnabled<\/samp><\/li>\n\n\n\n<li>\u60a8\u53ef\u4ee5\u968f\u65f6\u6dfb\u52a0\u6216\u5220\u9664\u6279\u6ce8\uff0c\u5373\u4f7f\u5728\u6258\u7ba1\u4e0a\u4e5f\u662f\u5982\u6b64 \u5e76\u53d1\u5e03\u4e86 Apex \u4ee3\u7801\u3002\u786e\u4fdd\u6ca1\u6709\u4f9d\u8d56\u5305 \u5728\u6dfb\u52a0\u6216\u5220\u9664\u4e4b\u524d\u4f9d\u8d56\u6ce8\u91ca\u7684\u529f\u80fd \u5b83\u3002<samp>@NamespaceAccessible<\/samp><\/li>\n\n\n\n<li>\u5728\u8f6f\u4ef6\u5305\u4e2d\u6dfb\u52a0\u6216\u5220\u9664 Apex \u65f6\uff0c\u8bf7\u8003\u8651\u5f71\u54cd \u5bf9\u4e8e\u5b89\u88c5\u4e86\u5f15\u7528\u6b64\u5305\u7684\u5176\u4ed6\u5305\u7248\u672c\u7684\u5ba2\u6237 \u5305\u7684\u6ce8\u89e3\u3002\u5728\u63a8\u9001\u8f6f\u4ef6\u5305\u5347\u7ea7\u4e4b\u524d\uff0c\u8bf7\u786e\u4fdd\u6ca1\u6709 \u5ba2\u6237\u6b63\u5728\u8fd0\u884c\u7684\u5305\u7248\u672c\u5728\u4ee5\u4e0b\u60c5\u51b5\u4e0b\u65e0\u6cd5\u5b8c\u5168\u7f16\u8bd1 \u5df2\u63a8\u9001\u5347\u7ea7\u3002<samp>@NamespaceAccessible<\/samp><\/li>\n\n\n\n<li>\u5982\u679c\u516c\u5171\u63a5\u53e3\u58f0\u660e\u4e3a \uff0c\u5219\u6240\u6709\u63a5\u53e3\u6210\u5458\u90fd\u7ee7\u627f \u6ce8\u89e3\u3002\u4e0d\u80fd\u4f7f\u7528 \u5bf9\u5355\u4e2a\u63a5\u53e3\u6210\u5458\u8fdb\u884c\u6ce8\u91ca\u3002<samp>@NamespaceAccessible<\/samp><samp>@NamespaceAccessible<\/samp><\/li>\n\n\n\n<li>\u5982\u679c\u5c06\u516c\u5171\u53d8\u91cf\u6216\u53d7\u4fdd\u62a4\u7684\u53d8\u91cf\u6216\u65b9\u6cd5\u58f0\u660e\u4e3a \uff0c\u5219\u5176\u5b9a\u4e49\u7c7b \u5fc5\u987b\u662f\u5168\u5c40\u7684\u6216\u5e26\u6709\u6ce8\u91ca\u7684\u516c\u5171\u7684\u3002<samp>@NamespaceAccessible<\/samp><samp>@NamespaceAccessible<\/samp><\/li>\n\n\n\n<li>\u5982\u679c\u5c06\u516c\u5171\u6216\u53d7\u4fdd\u62a4\u7684\u5185\u90e8\u7c7b\u58f0\u660e\u4e3a \uff0c\u5219\u5176\u5c01\u95ed\u5f0f \u7c7b\u5fc5\u987b\u662f\u5e26\u6709\u6ce8\u91ca\u7684\u5168\u5c40\u7c7b\u6216\u516c\u5171\u7c7b\u3002<samp>@NamespaceAccessible<\/samp><samp>@NamespaceAccessible<\/samp><\/li>\n<\/ul>\n\n\n\n<p>\u6b64\u793a\u4f8b\u663e\u793a\u4e00\u4e2a\u6807\u6709\u6279\u6ce8\u7684 Apex \u7c7b\u3002\u8fd9 \u7c7b\u53ef\u4f9b\u540c\u4e00\u547d\u540d\u7a7a\u95f4\u4e2d\u7684\u5176\u4ed6\u5305\u8bbf\u95ee\u3002\u7b2c\u4e00\u4e2a \u6784\u9020\u51fd\u6570\u5728\u547d\u540d\u7a7a\u95f4\u4e2d\u4e5f\u53ef\u89c1\uff0c\u4f46\u7b2c\u4e8c\u4e2a\u6784\u9020\u51fd\u6570\u4e0d\u53ef\u89c1\u3002<\/p>\n\n\n\n<p><samp>@NamespaceAccessible<\/samp><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\/\/ A namespace-visible Apex class\n@NamespaceAccessible\npublic class MyClass {\n    private Boolean bypassFLS;\n\n    \/\/ A namespace-visible constructor that only allows secure use\n    @NamespaceAccessible\n    public MyClass() {\n        bypassFLS = false;\n    }\n\n    \/\/ A package private constructor that allows use in trusted contexts,\n    \/\/ but only internal to the package\n    public MyClass (Boolean bypassFLS) {\n        this.bypassFLS = bypassFLS;\n    }\n    @NamespaceAccessible\n    protected Boolean getBypassFLS() {\n       return bypassFLS;\n    }\n}<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">\u7248\u672c\u5316\u884c\u4e3a\u66f4\u6539<\/h2>\n\n\n\n<p>\u5728 API \u7248\u672c 47.0 \u53ca\u66f4\u9ad8\u7248\u672c\u4e2d@NamespaceAccessible\uff0c\u4e0d\u5141\u8bb8\u5728\u6807\u6709 @AuraEnabled\u3002\u56e0\u6b64\uff0c\u4ece\u8f6f\u4ef6\u5305\u5b89\u88c5\u7684 Aura \u6216 Lightning Web \u7ec4\u4ef6\u4e0d\u80fd \u4ece\u53e6\u4e00\u4e2a\u5305\u8c03\u7528 Apex \u65b9\u6cd5\uff0c\u5373\u4f7f\u4e24\u4e2a\u5305\u4f4d\u4e8e\u540c\u4e00\u547d\u540d\u7a7a\u95f4\u4e2d\u3002<\/p>\n\n\n\n<p>\u5728 API \u7248\u672c 50.0 \u53ca\u66f4\u9ad8\u7248\u672c\u4e2d\uff0c\u8303\u56f4\u548c\u53ef\u8bbf\u95ee\u6027\u89c4\u5219\u5728 Apex \u4e0a\u5f3a\u5236\u6267\u884c \u7528 \u6ce8\u91ca\u7684\u53d8\u91cf\u3001\u65b9\u6cd5\u3001\u5185\u90e8\u7c7b\u548c\u63a5\u53e3\u3002\u51fa\u4e8e\u8f85\u52a9\u529f\u80fd\u8003\u8651\uff0c \u8bf7\u53c2\u9605&nbsp;Apex \u7684\u6ce8\u610f\u4e8b\u9879 \u8de8\u8f6f\u4ef6\u5305\u7684\u53ef\u8bbf\u95ee\u6027\u3002\u6709\u5173\u57fa\u4e8e\u547d\u540d\u7a7a\u95f4\u7684\u53ef\u89c1\u6027\u7684\u8be6\u7ec6\u4fe1\u606f\uff0c \u8bf7\u53c2\u9605&nbsp;Apex \u7684\u57fa\u4e8e\u547d\u540d\u7a7a\u95f4\u7684\u53ef\u89c1\u6027 \u7b2c\u4e8c\u4ee3\u5305\u4e2d\u7684\u7c7b\u3002<samp>@NamespaceAccessible<\/samp><\/p>\n\n\n\n<h1 class=\"wp-block-heading\">\u53ea\u8bfb\u6ce8\u89e3<\/h1>\n\n\n\n<p><a><\/a>\u8be5\u6ce8\u91ca\u5141\u8bb8\u60a8 \u901a\u8fc7\u589e\u52a0\u9650\u5236\uff0c\u5bf9 Lightning \u5e73\u53f0\u6570\u636e\u5e93\u6267\u884c\u9650\u5236\u8f83\u5c11\u7684\u67e5\u8be2 \u8bf7\u6c42\u8fd4\u56de\u7684\u884c\u6570\u4e3a 1,000,000\u3002\u6240\u6709\u5176\u4ed6\u9650\u5236\u4ecd\u7136\u9002\u7528\u3002\u8fd9 \u6ce8\u91ca\u4f1a\u963b\u6b62\u8bf7\u6c42\u4e2d\u7684\u4ee5\u4e0b\u64cd\u4f5c\uff1aDML \u64cd\u4f5c\u3001\u5bf9 \u7684\u8c03\u7528\u548c\u6392\u961f\u7684\u5f02\u6b65 Apex \u4f5c\u4e1a\u3002<samp>@ReadOnly<\/samp><samp>System.schedule<\/samp><\/p>\n\n\n\n<p><a><\/a>\u6ce8\u91ca\u53ef\u7528\u4e8e REST \u548c SOAP Web \u670d\u52a1\u4ee5\u53ca\u63a5\u53e3\u3002\u82e5\u8981\u4f7f\u7528\u6ce8\u91ca\uff0c\u9876\u7ea7\u8bf7\u6c42\u5fc5\u987b\u4f4d\u4e8e\u8ba1\u5212\u4e2d \u6267\u884c\u6216 Web \u670d\u52a1\u8c03\u7528\u3002\u4f8b\u5982\uff0c\u5982\u679c Visualforce \u9875\u9762\u8c03\u7528 \u5305\u542b\u6279\u6ce8\u7684 Web \u670d\u52a1\uff0c\u8bf7\u6c42\u5931\u8d25\uff0c\u56e0\u4e3a Visualforce \u662f\u9876\u7ea7\u8bf7\u6c42\uff0c\u800c\u4e0d\u662f Web \u670d\u52a1\u3002<samp>@ReadOnly<\/samp><samp>Schedulable<\/samp><samp>@ReadOnly<\/samp><samp>@ReadOnly<\/samp><\/p>\n\n\n\n<p>Visualforce \u9875\u9762\u53ef\u4ee5\u4f7f\u7528\u6ce8\u91ca\u8c03\u7528\u63a7\u5236\u5668\u65b9\u6cd5\uff0c\u8fd9\u4e9b\u65b9\u6cd5\u4f7f\u7528 \u540c\u6837\u653e\u5bbd\u4e86\u9650\u5236\u3002\u8981\u589e\u52a0\u5176\u4ed6\u7279\u5b9a\u4e8e Visualforce \u7684\u9650\u5236\uff0c\u4f8b\u5982 \u4f5c\u4e3a\u53ef\u4f9b\u8fed\u4ee3\u7ec4\u4ef6\u4f7f\u7528\u7684\u96c6\u5408\u7684\u5927\u5c0f\uff0c\u4f8b\u5982 \uff0c\u60a8\u53ef\u4ee5\u5c06\u6807\u8bb0\u4e0a\u7684\u5c5e\u6027\u8bbe\u7f6e\u4e3a \u3002\u6709\u5173\u66f4\u591a\u4fe1\u606f\uff0c\u8bf7\u53c2\u89c1&nbsp;Visualforce Developer \u7684 \u6307\u5357\u3002<samp>@ReadOnly&lt;apex:pageBlockTable&gt;readonly&lt;apex:page&gt;true<\/samp><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\u7248\u672c\u5316\u884c\u4e3a\u66f4\u6539<\/h2>\n\n\n\n<p>\u5728 API \u7248\u672c 49.0 \u4e4b\u524d\uff0c\u5728 Apex \u4e0a\u4f7f\u7528 \u8fd8\u9700\u8981 REST \u65b9\u6cd5\uff08@HttpDelete\u3001@HttpGet\u3001@HttpPatch\u3001@HttpPost \u6216 @HttpPut\uff09 \u7528 \u6ce8\u91ca\u65b9\u6cd5\u3002\u5728 API \u4e2d \u7248\u672c 49.0 \u53ca\u66f4\u9ad8\u7248\u672c\u4e2d\uff0c\u60a8\u53ef\u4ee5\u4ec5\u4f7f\u7528 .<samp>@ReadOnly<\/samp><samp>@RemoteAction<\/samp><samp>@ReadOnly<\/samp><\/p>\n\n\n\n<h1 class=\"wp-block-heading\">\u8fdc\u7a0b\u64cd\u4f5c\u6ce8\u89e3<\/h1>\n\n\n\n<p id=\"annotation_defn\"><a><\/a>\u6ce8\u91ca \u652f\u6301\u901a\u8fc7 JavaScript \u8c03\u7528 Visualforce \u4e2d\u4f7f\u7528\u7684 Apex \u65b9\u6cd5\u3002\u8fd9 \u8fdb\u7a0b\u901a\u5e38\u79f0\u4e3a JavaScript \u8fdc\u7a0b\u5904\u7406\u3002<samp>RemoteAction<\/samp><\/p>\n\n\n\n<p>\u6ce8\u610f<\/p>\n\n\n\n<p>\u5e26\u6709\u6ce8\u91ca\u7684\u65b9\u6cd5\u5fc5\u987b\u662f \u548c \u6216 \u3002<samp>RemoteAction<\/samp><samp>static<\/samp><samp>global<\/samp><samp>public<\/samp>\u5c06 Apex \u7c7b\u4f5c\u4e3a\u81ea\u5b9a\u4e49\u63a7\u5236\u5668\u6216\u63a7\u5236\u5668\u6269\u5c55\u6dfb\u52a0\u5230 \u9875\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;apex:page controller=\"MyController\" extension=\"MyExtension\"&gt;<\/code><\/pre>\n\n\n\n<p>\u8b66\u544a<\/p>\n\n\n\n<p>\u6dfb\u52a0\u63a7\u5236\u5668\u6216\u63a7\u5236\u5668\u6269\u5c55\u5c06\u6388\u4e88\u5bf9\u8be5 Apex \u7c7b\u4e2d\u6240\u6709\u65b9\u6cd5\u7684\u8bbf\u95ee\u6743\u9650\uff0c\u5373\u4f7f\u8fd9\u4e9b\u65b9\u6cd5 \u9875\u9762\u4e2d\u4e0d\u4f7f\u7528\u65b9\u6cd5\u3002\u4efb\u4f55\u53ef\u4ee5\u67e5\u770b\u8be5\u9875\u9762\u7684\u4eba\u90fd\u53ef\u4ee5\u6267\u884c\u6240\u6709\u65b9\u6cd5\uff0c\u5e76\u5411 \u63a7\u5236\u5668\u3002<samp>@RemoteAction<\/samp><samp>@RemoteAction<\/samp>\u7136\u540e\uff0c\u5c06\u8bf7\u6c42\u6dfb\u52a0\u4e3a JavaScript \u51fd\u6570\u8c03\u7528\u3002\u4e00\u4e2a\u7b80\u5355\u7684 JavaScript \u8fdc\u7a0b\u8c03\u7528\u91c7\u7528\u4ee5\u4e0b\u65b9\u6cd5 \u5f62\u5f0f\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&#91;<em>namespace<\/em>.]<em>MyController<\/em>.<em>method<\/em>(\n    &#91;parameters...,]\n    <em>callbackFunction<\/em>,\n    &#91;configuration]\n);<\/code><\/pre>\n\n\n\n<figure class=\"wp-block-table\"><table><thead><tr><th>\u5143\u7d20<\/th><th>\u63cf\u8ff0<\/th><\/tr><\/thead><tbody><tr><td><samp>namespace<\/samp><\/td><td>\u63a7\u5236\u5668\u7c7b\u7684\u547d\u540d\u7a7a\u95f4\u3002\u5982\u679c\u51fa\u73b0\u4ee5\u4e0b\u60c5\u51b5\uff0c\u5219 namespace \u5143\u7d20\u662f\u5fc5\u9700\u7684 \u60a8\u7684\u7ec4\u7ec7\u5b9a\u4e49\u4e86\u4e00\u4e2a\u547d\u540d\u7a7a\u95f4\uff0c\u6216\u8005\u8be5\u7c7b\u662f\u5426\u6765\u81ea\u5df2\u5b89\u88c5\u7684 \u5305\u3002<\/td><\/tr><tr><td><samp>MyController<\/samp>,<samp>MyExtension<\/samp><\/td><td>Apex \u63a7\u5236\u5668\u6216\u6269\u5c55\u7684\u540d\u79f0\u3002<\/td><\/tr><tr><td><samp>method<\/samp><\/td><td>\u8981\u8c03\u7528\u7684 Apex \u65b9\u6cd5\u7684\u540d\u79f0\u3002<\/td><\/tr><tr><td><samp>parameters<\/samp><\/td><td>\u65b9\u6cd5\u91c7\u7528\u7684\u53c2\u6570\u7684\u9017\u53f7\u5206\u9694\u5217\u8868\u3002<\/td><\/tr><tr><td><samp>callbackFunction<\/samp><\/td><td>\u5904\u7406\u6765\u81ea \u63a7\u5236\u5668\u3002\u8fd8\u53ef\u4ee5\u4ee5\u5185\u8054\u65b9\u5f0f\u58f0\u660e\u533f\u540d\u51fd\u6570\u3002 \u63a5\u6536\u65b9\u6cd5\u7684\u72b6\u6001 \u8c03\u7528\u548c\u7ed3\u679c\u4f5c\u4e3a\u53c2\u6570\u3002<samp>callbackFunction<\/samp><\/td><\/tr><tr><td><samp>configuration<\/samp><\/td><td>\u914d\u7f6e\u8fdc\u7a0b\u547c\u53eb\u548c\u54cd\u5e94\u7684\u5904\u7406\u3002\u4f7f\u7528\u6b64\u5143\u7d20\u53ef\u4ee5 \u66f4\u6539\u8fdc\u7a0b\u5904\u7406\u8c03\u7528\u7684\u884c\u4e3a\uff0c\u4f8b\u5982\u662f\u5426\u8f6c\u4e49 Apex \u65b9\u6cd5\u7684\u54cd\u5e94\u3002<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p>\u5728\u63a7\u5236\u5668\u4e2d\uff0cApex \u65b9\u6cd5\u58f0\u660e\u524d\u9762\u5e26\u6709\u7c7b\u4f3c \u8fd9\uff1a<\/p>\n\n\n\n<p><samp>@RemoteAction<\/samp><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>@RemoteAction\nglobal static String getItemId(String objectName) { ... }<\/code><\/pre>\n\n\n\n<p>Apex \u65b9\u6cd5\u5fc5\u987b\u662f \u548c \u6216 \u3002<\/p>\n\n\n\n<p><samp>@RemoteAction<\/samp><samp>static<\/samp><samp>global<\/samp><samp>public<\/samp><\/p>\n\n\n\n<p>\u60a8\u7684\u65b9\u6cd5\u53ef\u4ee5\u91c7\u7528 Apex \u57fa\u5143\u3001\u96c6\u5408\u3001\u7c7b\u578b\u5316\u548c\u6cdb\u578b sObjects\uff0c\u4ee5\u53ca \u7528\u6237\u5b9a\u4e49\u7684 Apex \u7c7b\u548c\u63a5\u53e3\u4f5c\u4e3a\u53c2\u6570\u3002\u901a\u7528 sObject \u5fc5\u987b\u5177\u6709 ID \u6216 sobjectType \u503c\u6765\u6807\u8bc6\u5b9e\u9645\u7c7b\u578b\u3002\u63a5\u53e3\u53c2\u6570\u5fc5\u987b\u5177\u6709 apexType \u786e\u5b9a\u5b9e\u9645\u7c7b\u578b\u3002\u60a8\u7684\u65b9\u6cd5\u53ef\u4ee5\u8fd4\u56de Apex \u57fa\u5143\u3001sObjects\u3001\u96c6\u5408\u3001 \u7528\u6237\u5b9a\u4e49\u7684 Apex \u7c7b\u548c\u679a\u4e3e\u3001 \u3001 \u3001 \u6216 \u3002<samp>SaveResult<\/samp><samp>UpsertResult<\/samp><samp>DeleteResult<\/samp><samp>SelectOption<\/samp><samp>PageReference<\/samp><\/p>\n\n\n\n<p>\u6709\u5173\u8be6\u7ec6\u4fe1\u606f\uff0c\u8bf7\u53c2\u9605\u300aVisualforce \u5f00\u53d1\u4eba\u5458\u6307\u5357\u300b\u4e2d\u7684\u201c\u9002\u7528\u4e8e Apex \u63a7\u5236\u5668\u7684 JavaScript \u8fdc\u7a0b\u5904\u7406\u201d\u3002<\/p>\n\n\n\n<h1 class=\"wp-block-heading\">\u6291\u5236\u8b66\u544a\u6ce8\u89e3<\/h1>\n\n\n\n<p>\u6b64\u6ce8\u91ca\u5728 Apex \u4e2d\u4e0d\u6267\u884c\u4efb\u4f55\u64cd\u4f5c\uff0c\u4f46\u53ef\u7528\u4e8e\u5411 \u7b2c\u4e09\u65b9\u5de5\u5177\u3002<\/p>\n\n\n\n<p><a><\/a>\u6ce8\u91ca\u5728 Apex \u4e2d\u4e0d\u6267\u884c\u4efb\u4f55\u64cd\u4f5c\uff0c\u4f46\u53ef\u7528\u4e8e\u5411 \u7b2c\u4e09\u65b9\u5de5\u5177\u3002<samp>@SuppressWarnings<\/samp><\/p>\n\n\n\n<h1 class=\"wp-block-heading\">\u6d4b\u8bd5\u8bbe\u7f6e\u6ce8\u89e3<\/h1>\n\n\n\n<p>\u4f7f\u7528\u6ce8\u89e3\u5b9a\u4e49\u7684\u65b9\u6cd5 \u7528\u4e8e\u521b\u5efa\u53ef\u7528\u4e8e \u7c7b\u3002<\/p>\n\n\n\n<p><samp>@TestSetup<\/samp><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\u8bed\u6cd5<\/h2>\n\n\n\n<p>\u6d4b\u8bd5\u8bbe\u7f6e\u65b9\u6cd5\u662f\u5728\u6d4b\u8bd5\u7c7b\u4e2d\u5b9a\u4e49\u7684\uff0c\u4e0d\u5e26\u4efb\u4f55\u53c2\u6570\uff0c\u4e5f\u4e0d\u8fd4\u56de\u4efb\u4f55\u503c\u3002\u8fd9 \u4ee5\u4e0b\u662f\u6d4b\u8bd5\u8bbe\u7f6e\u65b9\u6cd5\u7684\u8bed\u6cd5\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>@TestSetup static void methodName() {\n\n}<\/code><\/pre>\n\n\n\n<p>\u5982\u679c\u6d4b\u8bd5\u7c7b\u5305\u542b\u6d4b\u8bd5\u8bbe\u7f6e\u65b9\u6cd5\uff0c\u5219\u6d4b\u8bd5\u6846\u67b6\u5c06\u6267\u884c\u6d4b\u8bd5\u8bbe\u7f6e \u65b9\u6cd5\uff0c\u5728\u7c7b\u4e2d\u7684\u4efb\u4f55\u6d4b\u8bd5\u65b9\u6cd5\u4e4b\u524d\u3002\u5728\u6d4b\u8bd5\u8bbe\u7f6e\u4e2d\u521b\u5efa\u7684\u8bb0\u5f55 \u65b9\u6cd5\u53ef\u7528\u4e8e\u6d4b\u8bd5\u7c7b\u4e2d\u7684\u6240\u6709\u6d4b\u8bd5\u65b9\u6cd5\uff0c\u5e76\u5728 \u6d4b\u8bd5\u7c7b\u6267\u884c\u3002\u5982\u679c\u6d4b\u8bd5\u65b9\u6cd5\u66f4\u6539\u4e86\u8fd9\u4e9b\u8bb0\u5f55\uff0c\u4f8b\u5982\u8bb0\u5f55\u5b57\u6bb5\u66f4\u65b0\u6216 \u8bb0\u5f55\u5220\u9664\uff0c\u8fd9\u4e9b\u66f4\u6539\u5c06\u5728\u6bcf\u4e2a\u6d4b\u8bd5\u65b9\u6cd5\u5b8c\u6210\u6267\u884c\u540e\u56de\u6eda\u3002\u8fd9 \u63a5\u4e0b\u6765\uff0c\u6267\u884c\u6d4b\u8bd5\u65b9\u6cd5\u53ef\u4ee5\u8bbf\u95ee\u8fd9\u4e9b\u8bb0\u5f55\u7684\u539f\u59cb\u672a\u4fee\u6539\u72b6\u6001\u3002<\/p>\n\n\n\n<p>\u6ce8\u610f<\/p>\n\n\n\n<p>\u6bcf\u4e2a\u6d4b\u8bd5\u7c7b\u53ea\u80fd\u6709\u4e00\u79cd\u6d4b\u8bd5\u8bbe\u7f6e\u65b9\u6cd5\u3002<\/p>\n\n\n\n<p>\u53ea\u6709\u6d4b\u8bd5\u7c7b\u7684\u9ed8\u8ba4\u6570\u636e\u9694\u79bb\u6a21\u5f0f\u624d\u652f\u6301\u6d4b\u8bd5\u8bbe\u7f6e\u65b9\u6cd5\u3002 \u5982\u679c\u6d4b\u8bd5\u7c7b\u6216\u6d4b\u8bd5\u65b9\u6cd5\u53ef\u4ee5\u4f7f\u7528\u6279\u6ce8\u8bbf\u95ee\u7ec4\u7ec7\u6570\u636e\uff0c \u6b64\u7c7b\u4e0d\u652f\u6301\u6d4b\u8bd5\u8bbe\u7f6e\u65b9\u6cd5\u3002\u56e0\u4e3a\u6d4b\u8bd5\u7684\u6570\u636e\u9694\u79bb \u9002\u7528\u4e8e API \u7248\u672c 24.0 \u53ca\u66f4\u9ad8\u7248\u672c\uff0c\u4e5f\u63d0\u4f9b\u6d4b\u8bd5\u8bbe\u7f6e\u65b9\u6cd5 \u4ec5\u9002\u7528\u4e8e\u8fd9\u4e9b\u7248\u672c\u3002<samp>@IsTest(SeeAllData=true)<\/samp><\/p>\n\n\n\n<h1 class=\"wp-block-heading\">\u6d4b\u8bd5\u53ef\u89c1\u6ce8\u89e3<\/h1>\n\n\n\n<p>\u4f7f\u7528\u6ce8\u91ca \u5141\u8bb8\u6d4b\u8bd5\u65b9\u6cd5\u8bbf\u95ee\u53e6\u4e00\u4e2a\u6210\u5458\u7684\u79c1\u6709\u6216\u53d7\u4fdd\u62a4\u6210\u5458 \u6d4b\u8bd5\u7c7b\u4e4b\u5916\u7684\u7c7b\u3002\u8fd9\u4e9b\u6210\u5458\u5305\u62ec\u65b9\u6cd5\u3001\u6210\u5458 \u53d8\u91cf\u548c\u5185\u90e8\u7c7b\u3002\u6b64\u6ce8\u91ca\u53ef\u5b9e\u73b0\u66f4\u5bbd\u677e\u7684 \u4ec5\u7528\u4e8e\u8fd0\u884c\u6d4b\u8bd5\u7684\u8bbf\u95ee\u7ea7\u522b\u3002\u6b64\u6ce8\u89e3\u4e0d \u5982\u679c\u975e\u6d4b\u8bd5\u7c7b\u8bbf\u95ee\u6210\u5458\uff0c\u5219\u66f4\u6539\u6210\u5458\u7684\u53ef\u89c1\u6027\u3002<samp>TestVisible<\/samp><\/p>\n\n\n\n<p>\u4f7f\u7528\u6b64\u6ce8\u91ca\uff0c\u60a8\u4e0d\u5fc5\u66f4\u6539\u65b9\u6cd5\u7684\u8bbf\u95ee\u4fee\u9970\u7b26\uff0c\u5e76\u4e14 \u5982\u679c\u8981\u5728\u6d4b\u8bd5\u65b9\u6cd5\u4e2d\u8bbf\u95ee\u5b83\u4eec\uff0c\u5219\u5c06\u53d8\u91cf\u6dfb\u52a0\u5230 public\u3002\u4f8b\u5982\uff0c\u5982\u679c \u79c1\u6709\u6210\u5458\u53d8\u91cf\u4e0d\u5e94\u8be5\u66b4\u9732\u7ed9\u5916\u90e8\u7c7b\uff0c\u4f46\u5b83 \u5fc5\u987b\u53ef\u901a\u8fc7\u6d4b\u8bd5\u65b9\u6cd5\u8bbf\u95ee\uff0c\u624d\u80fd\u5c06\u6ce8\u91ca\u6dfb\u52a0\u5230\u53d8\u91cf\u5b9a\u4e49\u4e2d\u3002<samp>TestVisible<\/samp><\/p>\n\n\n\n<p>\u6b64\u793a\u4f8b\u6f14\u793a\u5982\u4f55\u5bf9\u79c1\u6709\u7c7b\u6210\u5458\u53d8\u91cf\u8fdb\u884c\u6279\u6ce8 \u548c\u79c1\u6709\u65b9\u6cd5\u3002<samp>TestVisible<\/samp><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>public class TestVisibleExample {\n    \/\/ Private member variable\n    @TestVisible private static Integer recordNumber = 1;\n\n    \/\/ Private method\n    @TestVisible private static void updateRecord(String name) {\n        \/\/ Do something\n    }\n}<\/code><\/pre>\n\n\n\n<p>\u6b64\u6d4b\u8bd5\u7c7b\u4f7f\u7528\u4e0a\u4e00\u4e2a\u7c7b\uff0c\u5e76\u5305\u542b\u8bbf\u95ee\u5e26\u6ce8\u91ca\u7684 \u6210\u5458\u53d8\u91cf\u548c\u65b9\u6cd5\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>@IsTest\nprivate class TestVisibleExampleTest {\n    @IsTest static void test1() {\n        \/\/ Access private variable annotated with TestVisible\n        Integer i = TestVisibleExample.recordNumber;\n        System.assertEquals(1, i);\n\n        \/\/ Access private method annotated with TestVisible\n        TestVisibleExample.updateRecord('RecordName');\n        \/\/ Perform some verification\n    }\n}<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">Apex REST \u6ce8\u89e3<\/h2>\n\n\n\n<p>\u4f7f\u7528\u8fd9\u4e9b\u6ce8\u89e3\u5c06 Apex \u7c7b\u516c\u5f00\u4e3a RESTful Web \u670d\u52a1\u3002<\/p>\n\n\n\n<ul class=\"wp-block-list\" id=\"RestAnnotations\">\n<li><samp>@ReadOnly<\/samp><\/li>\n\n\n\n<li><samp>@RestResource(urlMapping=&#8217;\/<var>yourUrl<\/var>&#8216;)<\/samp><\/li>\n\n\n\n<li><samp>@HttpDelete<\/samp><\/li>\n\n\n\n<li><samp>@HttpGet<\/samp><\/li>\n\n\n\n<li><samp>@HttpPatch<\/samp><\/li>\n\n\n\n<li><samp>@HttpPost<\/samp><\/li>\n\n\n\n<li><samp>@HttpPut<\/samp><\/li>\n<\/ul>\n\n\n\n<h1 class=\"wp-block-heading\">RestResource Annotation<\/h1>\n\n\n\n<p><a><\/a>\u6ce8\u91ca\u7528\u4e8e \u7c7b\u7ea7\u522b\uff0c\u4f7f\u60a8\u80fd\u591f\u5c06 Apex \u7c7b\u516c\u5f00\u4e3a REST \u8d44\u6e90\u3002<samp>@RestResource<\/samp>\u4f7f\u7528\u6b64\u6ce8\u91ca\u65f6\u7684\u4e00\u4e9b\u6ce8\u610f\u4e8b\u9879\uff1a<\/p>\n\n\n\n<ul class=\"wp-block-list\" id=\"url_mapping\">\n<li>URL \u6620\u5c04\u662f\u76f8\u5bf9\u4e8e&nbsp;https:\/\/&nbsp;<var>instance.salesforce.com\/services\/apexrest\/<\/var>&nbsp;\u7684\u3002<\/li>\n\n\n\n<li>URL \u6620\u5c04\u53ef\u4ee5\u5305\u542b\u901a\u914d\u7b26 \uff08*\uff09\u3002<\/li>\n\n\n\n<li>URL \u6620\u5c04\u533a\u5206\u5927\u5c0f\u5199\u3002\u4f8b\u5982\uff0c\u7684 URL \u6620\u5c04\u4e0e\u5305\u542b \u800c\u4e0d\u662f \u7684 REST \u8d44\u6e90\u5339\u914d\u3002<samp>my_url<\/samp><samp>my_url<\/samp><samp>My_Url<\/samp><\/li>\n\n\n\n<li>\u8981\u4f7f\u7528\u6b64\u6ce8\u91ca\uff0c\u5fc5\u987b\u5c06 Apex \u7c7b\u5b9a\u4e49\u4e3a\u5168\u5c40\u7c7b\u3002<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">URL \u51c6\u5219<\/h2>\n\n\n\n<p>URL \u8def\u5f84\u6620\u5c04\u5982\u4e0b\u6240\u793a\uff1a<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u8def\u5f84\u5fc5\u987b\u4ee5\u6b63\u659c\u6760 \uff08\/\uff09 \u5f00\u5934\u3002<\/li>\n\n\n\n<li>\u8def\u5f84\u957f\u5ea6\u6700\u591a\u4e3a 255 \u4e2a\u5b57\u7b26\u3002<\/li>\n\n\n\n<li>\u8def\u5f84\u4e2d\u51fa\u73b0\u7684\u901a\u914d\u7b26 \uff08*\uff09 \u524d\u9762\u5fc5\u987b\u6709\u6b63\u659c\u6760 \uff08\/\uff09\u3002 \u6b64\u5916\uff0c\u9664\u975e\u901a\u914d\u7b26\u662f\u8def\u5f84\u4e2d\u7684\u6700\u540e\u4e00\u4e2a\u5b57\u7b26\uff0c\u5426\u5219\u5fc5\u987b\u9075\u5faa\u901a\u914d\u7b26 \u6b63\u659c\u6760 \uff08\/\uff09\u3002<\/li>\n<\/ul>\n\n\n\n<p>\u6620\u5c04 URL \u7684\u89c4\u5219\u5982\u4e0b\uff1a<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u5b8c\u5168\u5339\u914d\u603b\u662f\u83b7\u80dc\u3002<\/li>\n\n\n\n<li>\u5982\u679c\u672a\u627e\u5230\u5b8c\u5168\u5339\u914d\u9879\uff0c\u8bf7\u67e5\u627e\u5177\u6709\u5339\u914d\u901a\u914d\u7b26\u7684\u6240\u6709\u6a21\u5f0f\uff0c\u7136\u540e\u9009\u62e9 \u5176\u4e2d\u6700\u957f\u7684\uff08\u6309\u5b57\u7b26\u4e32\u957f\u5ea6\u8ba1\u7b97\uff09\u3002<\/li>\n\n\n\n<li>\u5982\u679c\u672a\u627e\u5230\u901a\u914d\u7b26\u5339\u914d\u9879\uff0c\u5219\u8fd4\u56de HTTP \u54cd\u5e94\u72b6\u6001\u4ee3\u7801 404\u3002<\/li>\n<\/ul>\n\n\n\n<p>\u547d\u540d\u7a7a\u95f4\u7c7b\u7684 URL \u5305\u542b\u547d\u540d\u7a7a\u95f4\u3002\u4f8b\u5982\uff0c\u5982\u679c\u60a8\u7684\u7c7b\u4f4d\u4e8e\u547d\u540d\u7a7a\u95f4\u4e2d\uff0c\u5e76\u4e14\u8be5\u7c7b\u6620\u5c04\u5230 \uff0c\u5219 API URL \u5c06\u4fee\u6539\u5982\u4e0b\uff1ahttps:\/\/&nbsp;<var>instance.salesforce.com\/services\/apexrest\/abc\/your_url\/<\/var>\u3002 \u5728\u53d1\u751f URL \u51b2\u7a81\u7684\u60c5\u51b5\u4e0b\uff0c\u59cb\u7ec8\u4f7f\u7528\u547d\u540d\u7a7a\u95f4\u7c7b\u3002<samp>abc<\/samp><samp>your_url<\/samp><\/p>\n\n\n\n<h1 class=\"wp-block-heading\">Http\u5220\u9664\u6ce8\u89e3<\/h1>\n\n\n\n<p>\u6ce8\u91ca\u5728\u65b9\u6cd5\u7ea7\u522b\u4f7f\u7528 \u5e76\u4f7f\u60a8\u80fd\u591f\u5c06 Apex \u65b9\u6cd5\u516c\u5f00\u4e3a REST \u8d44\u6e90\u3002\u6b64\u65b9\u6cd5\u5728\u53d1\u9001 HTTP \u8bf7\u6c42\u65f6\u8c03\u7528\uff0c\u5e76\u5220\u9664\u6307\u5b9a\u7684 \u8d44\u6e90\u3002<samp>@HttpDelete<\/samp><samp>DELETE<\/samp><\/p>\n\n\n\n<p><a><\/a>\u82e5\u8981\u4f7f\u7528\u6b64\u6279\u6ce8\uff0c\u5fc5\u987b\u5c06 Apex \u65b9\u6cd5\u5b9a\u4e49\u4e3a \u5168\u5c40\u9759\u6001\u3002<\/p>\n\n\n\n<h1 class=\"wp-block-heading\">HttpGet\u7684\u6ce8\u89e3<\/h1>\n\n\n\n<p>\u6ce8\u91ca\u7528\u4e8e\u65b9\u6cd5\u7ea7\u522b\u548c \u4f7f\u60a8\u80fd\u591f\u5c06 Apex \u65b9\u6cd5\u516c\u5f00\u4e3a REST \u8d44\u6e90\u3002\u6b64\u65b9\u6cd5\u5728\u53d1\u9001 HTTP \u8bf7\u6c42\u65f6\u8c03\u7528\uff0c\u5e76\u8fd4\u56de\u6307\u5b9a\u7684 \u8d44\u6e90\u3002<samp>@HttpGet<\/samp><samp>GET<\/samp>\u4ee5\u4e0b\u662f\u4f7f\u7528\u6b64\u6ce8\u91ca\u65f6\u7684\u4e00\u4e9b\u6ce8\u610f\u4e8b\u9879\uff1a<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u82e5\u8981\u4f7f\u7528\u6b64\u6ce8\u91ca\uff0c\u5fc5\u987b\u5c06 Apex \u65b9\u6cd5\u5b9a\u4e49\u4e3a\u5168\u5c40\u9759\u6001\u65b9\u6cd5\u3002<\/li>\n\n\n\n<li>\u6ce8\u91ca\u7684\u65b9\u6cd5\u4e5f\u79f0\u4e3a if HTTP \u8bf7\u6c42\u4f7f\u7528 request \u65b9\u6cd5\u3002<samp>@HttpGet<\/samp><samp>HEAD<\/samp><\/li>\n<\/ul>\n\n\n\n<h1 class=\"wp-block-heading\">HttpPatch&nbsp;\u7684\u6ce8\u89e3<\/h1>\n\n\n\n<p>\u6ce8\u91ca\u5728\u65b9\u6cd5\u7ea7\u522b\u4f7f\u7528 \u5e76\u4f7f\u60a8\u80fd\u591f\u5c06 Apex \u65b9\u6cd5\u516c\u5f00\u4e3a REST \u8d44\u6e90\u3002\u6b64\u65b9\u6cd5\u5728\u53d1\u9001 HTTP \u8bf7\u6c42\u65f6\u8c03\u7528\uff0c\u5e76\u66f4\u65b0\u6307\u5b9a\u7684 \u8d44\u6e90\u3002<samp>@HttpPatch<\/samp><samp>PATCH<\/samp><\/p>\n\n\n\n<p>\u82e5\u8981\u4f7f\u7528\u6b64\u6ce8\u91ca\uff0c\u5fc5\u987b\u5c06 Apex \u65b9\u6cd5\u5b9a\u4e49\u4e3a\u5168\u5c40\u9759\u6001\u65b9\u6cd5\u3002<\/p>\n\n\n\n<h1 class=\"wp-block-heading\">HttpPost\u7684\u6ce8\u89e3<\/h1>\n\n\n\n<p>\u6ce8\u91ca\u7528\u4e8e\u65b9\u6cd5 \u7ea7\u522b\uff0c\u5e76\u4f7f\u60a8\u80fd\u591f\u5c06 Apex \u65b9\u6cd5\u516c\u5f00\u4e3a REST \u8d44\u6e90\u3002\u6b64\u65b9\u6cd5\u79f0\u4e3a \u53d1\u9001 HTTP \u8bf7\u6c42\u65f6\uff0c\u5e76\u521b\u5efa\u4e00\u4e2a \u65b0\u8d44\u6e90\u3002<samp>@HttpPost<\/samp><samp>POST<\/samp><\/p>\n\n\n\n<p>\u82e5\u8981\u4f7f\u7528\u6b64\u6ce8\u91ca\uff0c\u5fc5\u987b\u5c06 Apex \u65b9\u6cd5\u5b9a\u4e49\u4e3a\u5168\u5c40\u9759\u6001\u65b9\u6cd5\u3002<\/p>\n\n\n\n<h1 class=\"wp-block-heading\">HttpPut&nbsp;\u7684\u6ce8\u89e3<\/h1>\n\n\n\n<p>\u6ce8\u91ca\u7528\u4e8e\u65b9\u6cd5\u7ea7\u522b\u548c \u4f7f\u60a8\u80fd\u591f\u5c06 Apex \u65b9\u6cd5\u516c\u5f00\u4e3a REST \u8d44\u6e90\u3002\u6b64\u65b9\u6cd5\u5728\u53d1\u9001 HTTP \u8bf7\u6c42\u65f6\u8c03\u7528\uff0c\u5e76\u521b\u5efa\u6216\u66f4\u65b0\u6307\u5b9a\u7684 \u8d44\u6e90\u3002<samp>@HttpPut<\/samp><samp>PUT<\/samp><\/p>\n\n\n\n<p>\u82e5\u8981\u4f7f\u7528\u6b64\u6ce8\u91ca\uff0c\u5fc5\u987b\u5c06 Apex \u65b9\u6cd5\u5b9a\u4e49\u4e3a\u5168\u5c40\u9759\u6001\u65b9\u6cd5\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Apex \u6ce8\u89e3\u4fee\u6539\u4e86\u65b9\u6cd5\u6216\u7c7b\u7684\u4f7f\u7528\u65b9\u5f0f\uff0c\u7c7b\u4f3c\u4e8e Java \u4e2d\u7684\u6ce8\u89e3\u3002\u6ce8\u91ca\u4f7f\u7528\u521d\u59cb\u7b26\u53f7\u5b9a\u4e49\uff0c\u540e\u8ddf\u76f8\u5e94\u7684\u5173\u952e\u5b57\u3002@<\/p>\n","protected":false},"author":1,"featured_media":3639,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[199],"tags":[],"class_list":["post-3638","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-apex-"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v21.7 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Apex \u6ce8\u89e3 - \u767d\u767d\u968f\u7b14<\/title>\n<meta name=\"description\" content=\"Apex \u6ce8\u89e3\u4fee\u6539\u4e86\u65b9\u6cd5\u6216\u7c7b\u7684\u4f7f\u7528\u65b9\u5f0f\uff0c\u7c7b\u4f3c\u4e8e Java \u4e2d\u7684\u6ce8\u89e3\u3002\u6ce8\u91ca\u4f7f\u7528\u521d\u59cb\u7b26\u53f7\u5b9a\u4e49\uff0c\u540e\u8ddf\u76f8\u5e94\u7684\u5173\u952e\u5b57\u3002\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"http:\/\/www.ponybai.com\/?p=3638\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Apex \u6ce8\u89e3 - \u767d\u767d\u968f\u7b14\" \/>\n<meta property=\"og:description\" content=\"Apex \u6ce8\u89e3\u4fee\u6539\u4e86\u65b9\u6cd5\u6216\u7c7b\u7684\u4f7f\u7528\u65b9\u5f0f\uff0c\u7c7b\u4f3c\u4e8e Java \u4e2d\u7684\u6ce8\u89e3\u3002\u6ce8\u91ca\u4f7f\u7528\u521d\u59cb\u7b26\u53f7\u5b9a\u4e49\uff0c\u540e\u8ddf\u76f8\u5e94\u7684\u5173\u952e\u5b57\u3002\" \/>\n<meta property=\"og:url\" content=\"http:\/\/www.ponybai.com\/?p=3638\" \/>\n<meta property=\"og:site_name\" content=\"\u767d\u767d\u968f\u7b14\" \/>\n<meta property=\"article:published_time\" content=\"2023-11-21T06:39:21+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2023-11-21T07:02:54+00:00\" \/>\n<meta property=\"og:image\" content=\"http:\/\/www.ponybai.com\/wp-content\/uploads\/2023\/11\/Apex\u6ce8\u89e3.png\" \/>\n\t<meta property=\"og:image:width\" content=\"1120\" \/>\n\t<meta property=\"og:image:height\" content=\"433\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"ponybai\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"\u4f5c\u8005\" \/>\n\t<meta name=\"twitter:data1\" content=\"ponybai\" \/>\n\t<meta name=\"twitter:label2\" content=\"\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4\" \/>\n\t<meta name=\"twitter:data2\" content=\"6 \u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"http:\/\/www.ponybai.com\/?p=3638#article\",\"isPartOf\":{\"@id\":\"http:\/\/www.ponybai.com\/?p=3638\"},\"author\":{\"name\":\"ponybai\",\"@id\":\"http:\/\/www.ponybai.com\/#\/schema\/person\/935c7592c850c65e1e5eba4530dbf883\"},\"headline\":\"Apex \u6ce8\u89e3\",\"datePublished\":\"2023-11-21T06:39:21+00:00\",\"dateModified\":\"2023-11-21T07:02:54+00:00\",\"mainEntityOfPage\":{\"@id\":\"http:\/\/www.ponybai.com\/?p=3638\"},\"wordCount\":616,\"publisher\":{\"@id\":\"http:\/\/www.ponybai.com\/#\/schema\/person\/935c7592c850c65e1e5eba4530dbf883\"},\"articleSection\":[\"Apex \u5f00\u53d1\u4eba\u5458\u6307\u5357\"],\"inLanguage\":\"zh-Hans\"},{\"@type\":\"WebPage\",\"@id\":\"http:\/\/www.ponybai.com\/?p=3638\",\"url\":\"http:\/\/www.ponybai.com\/?p=3638\",\"name\":\"Apex \u6ce8\u89e3 - \u767d\u767d\u968f\u7b14\",\"isPartOf\":{\"@id\":\"http:\/\/www.ponybai.com\/#website\"},\"datePublished\":\"2023-11-21T06:39:21+00:00\",\"dateModified\":\"2023-11-21T07:02:54+00:00\",\"description\":\"Apex \u6ce8\u89e3\u4fee\u6539\u4e86\u65b9\u6cd5\u6216\u7c7b\u7684\u4f7f\u7528\u65b9\u5f0f\uff0c\u7c7b\u4f3c\u4e8e Java \u4e2d\u7684\u6ce8\u89e3\u3002\u6ce8\u91ca\u4f7f\u7528\u521d\u59cb\u7b26\u53f7\u5b9a\u4e49\uff0c\u540e\u8ddf\u76f8\u5e94\u7684\u5173\u952e\u5b57\u3002\",\"breadcrumb\":{\"@id\":\"http:\/\/www.ponybai.com\/?p=3638#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"http:\/\/www.ponybai.com\/?p=3638\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"http:\/\/www.ponybai.com\/?p=3638#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"http:\/\/www.ponybai.com\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Apex \u6ce8\u89e3\"}]},{\"@type\":\"WebSite\",\"@id\":\"http:\/\/www.ponybai.com\/#website\",\"url\":\"http:\/\/www.ponybai.com\/\",\"name\":\"\u767d\u767d\u968f\u7b14\",\"description\":\"Salesforce\u5b98\u65b9\u8bb2\u5e08\",\"publisher\":{\"@id\":\"http:\/\/www.ponybai.com\/#\/schema\/person\/935c7592c850c65e1e5eba4530dbf883\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"http:\/\/www.ponybai.com\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"zh-Hans\"},{\"@type\":[\"Person\",\"Organization\"],\"@id\":\"http:\/\/www.ponybai.com\/#\/schema\/person\/935c7592c850c65e1e5eba4530dbf883\",\"name\":\"ponybai\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-Hans\",\"@id\":\"http:\/\/www.ponybai.com\/#\/schema\/person\/image\/\",\"url\":\"http:\/\/www.ponybai.com\/wp-content\/uploads\/2025\/03\/cropped-Ihsans-WeChatQR.jpg\",\"contentUrl\":\"http:\/\/www.ponybai.com\/wp-content\/uploads\/2025\/03\/cropped-Ihsans-WeChatQR.jpg\",\"width\":248,\"height\":248,\"caption\":\"ponybai\"},\"logo\":{\"@id\":\"http:\/\/www.ponybai.com\/#\/schema\/person\/image\/\"},\"sameAs\":[\"http:\/\/121.37.188.161\"],\"url\":\"http:\/\/www.ponybai.com\/?author=1\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Apex \u6ce8\u89e3 - \u767d\u767d\u968f\u7b14","description":"Apex \u6ce8\u89e3\u4fee\u6539\u4e86\u65b9\u6cd5\u6216\u7c7b\u7684\u4f7f\u7528\u65b9\u5f0f\uff0c\u7c7b\u4f3c\u4e8e Java \u4e2d\u7684\u6ce8\u89e3\u3002\u6ce8\u91ca\u4f7f\u7528\u521d\u59cb\u7b26\u53f7\u5b9a\u4e49\uff0c\u540e\u8ddf\u76f8\u5e94\u7684\u5173\u952e\u5b57\u3002","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"http:\/\/www.ponybai.com\/?p=3638","og_locale":"zh_CN","og_type":"article","og_title":"Apex \u6ce8\u89e3 - \u767d\u767d\u968f\u7b14","og_description":"Apex \u6ce8\u89e3\u4fee\u6539\u4e86\u65b9\u6cd5\u6216\u7c7b\u7684\u4f7f\u7528\u65b9\u5f0f\uff0c\u7c7b\u4f3c\u4e8e Java \u4e2d\u7684\u6ce8\u89e3\u3002\u6ce8\u91ca\u4f7f\u7528\u521d\u59cb\u7b26\u53f7\u5b9a\u4e49\uff0c\u540e\u8ddf\u76f8\u5e94\u7684\u5173\u952e\u5b57\u3002","og_url":"http:\/\/www.ponybai.com\/?p=3638","og_site_name":"\u767d\u767d\u968f\u7b14","article_published_time":"2023-11-21T06:39:21+00:00","article_modified_time":"2023-11-21T07:02:54+00:00","og_image":[{"width":1120,"height":433,"url":"http:\/\/www.ponybai.com\/wp-content\/uploads\/2023\/11\/Apex\u6ce8\u89e3.png","type":"image\/png"}],"author":"ponybai","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"ponybai","\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4":"6 \u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"http:\/\/www.ponybai.com\/?p=3638#article","isPartOf":{"@id":"http:\/\/www.ponybai.com\/?p=3638"},"author":{"name":"ponybai","@id":"http:\/\/www.ponybai.com\/#\/schema\/person\/935c7592c850c65e1e5eba4530dbf883"},"headline":"Apex \u6ce8\u89e3","datePublished":"2023-11-21T06:39:21+00:00","dateModified":"2023-11-21T07:02:54+00:00","mainEntityOfPage":{"@id":"http:\/\/www.ponybai.com\/?p=3638"},"wordCount":616,"publisher":{"@id":"http:\/\/www.ponybai.com\/#\/schema\/person\/935c7592c850c65e1e5eba4530dbf883"},"articleSection":["Apex \u5f00\u53d1\u4eba\u5458\u6307\u5357"],"inLanguage":"zh-Hans"},{"@type":"WebPage","@id":"http:\/\/www.ponybai.com\/?p=3638","url":"http:\/\/www.ponybai.com\/?p=3638","name":"Apex \u6ce8\u89e3 - \u767d\u767d\u968f\u7b14","isPartOf":{"@id":"http:\/\/www.ponybai.com\/#website"},"datePublished":"2023-11-21T06:39:21+00:00","dateModified":"2023-11-21T07:02:54+00:00","description":"Apex \u6ce8\u89e3\u4fee\u6539\u4e86\u65b9\u6cd5\u6216\u7c7b\u7684\u4f7f\u7528\u65b9\u5f0f\uff0c\u7c7b\u4f3c\u4e8e Java \u4e2d\u7684\u6ce8\u89e3\u3002\u6ce8\u91ca\u4f7f\u7528\u521d\u59cb\u7b26\u53f7\u5b9a\u4e49\uff0c\u540e\u8ddf\u76f8\u5e94\u7684\u5173\u952e\u5b57\u3002","breadcrumb":{"@id":"http:\/\/www.ponybai.com\/?p=3638#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["http:\/\/www.ponybai.com\/?p=3638"]}]},{"@type":"BreadcrumbList","@id":"http:\/\/www.ponybai.com\/?p=3638#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"http:\/\/www.ponybai.com\/"},{"@type":"ListItem","position":2,"name":"Apex \u6ce8\u89e3"}]},{"@type":"WebSite","@id":"http:\/\/www.ponybai.com\/#website","url":"http:\/\/www.ponybai.com\/","name":"\u767d\u767d\u968f\u7b14","description":"Salesforce\u5b98\u65b9\u8bb2\u5e08","publisher":{"@id":"http:\/\/www.ponybai.com\/#\/schema\/person\/935c7592c850c65e1e5eba4530dbf883"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"http:\/\/www.ponybai.com\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"zh-Hans"},{"@type":["Person","Organization"],"@id":"http:\/\/www.ponybai.com\/#\/schema\/person\/935c7592c850c65e1e5eba4530dbf883","name":"ponybai","image":{"@type":"ImageObject","inLanguage":"zh-Hans","@id":"http:\/\/www.ponybai.com\/#\/schema\/person\/image\/","url":"http:\/\/www.ponybai.com\/wp-content\/uploads\/2025\/03\/cropped-Ihsans-WeChatQR.jpg","contentUrl":"http:\/\/www.ponybai.com\/wp-content\/uploads\/2025\/03\/cropped-Ihsans-WeChatQR.jpg","width":248,"height":248,"caption":"ponybai"},"logo":{"@id":"http:\/\/www.ponybai.com\/#\/schema\/person\/image\/"},"sameAs":["http:\/\/121.37.188.161"],"url":"http:\/\/www.ponybai.com\/?author=1"}]}},"_links":{"self":[{"href":"http:\/\/www.ponybai.com\/index.php?rest_route=\/wp\/v2\/posts\/3638","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/www.ponybai.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.ponybai.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.ponybai.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.ponybai.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=3638"}],"version-history":[{"count":2,"href":"http:\/\/www.ponybai.com\/index.php?rest_route=\/wp\/v2\/posts\/3638\/revisions"}],"predecessor-version":[{"id":3643,"href":"http:\/\/www.ponybai.com\/index.php?rest_route=\/wp\/v2\/posts\/3638\/revisions\/3643"}],"wp:featuredmedia":[{"embeddable":true,"href":"http:\/\/www.ponybai.com\/index.php?rest_route=\/wp\/v2\/media\/3639"}],"wp:attachment":[{"href":"http:\/\/www.ponybai.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=3638"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.ponybai.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=3638"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.ponybai.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=3638"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}