Hello Account (REST using cURL)

cURL で Hello Account。

$ curl -k -d grant_type=password -d client_id= -d client_secret= -d username= -d password= https://test.salesforce.com/services/oauth2/token -H 'X-PrettyPrint:1'

$ curl https://cs6.salesforce.com/services/data/v31.0/query?q=SELECT+Id+,+Name+FROM+Account -H 'Authorization: Bearer ' -H 'Content-Type: application/json' -H 'X-PrettyPrint:1'

Hello Account (JavaScript Remoting)

JavaScript Remoting で Hello Account。

<apex:page controller="HelloAccountRemoter">
    
<script type="text/javascript">
  function doGetAccounts() {
      HelloAccountRemoter.getAccounts(
        function(result, event) {
            for (var i = 0; i < result.length; i++) {
                console.log(result[i].Id, result[i].Name);
            }
        },
        {escape: true}
      );
  } 
</script>
    
<apex:form id="formId">
	<apex:commandButton onclick="doGetAccounts()" value="hello" rerender="formId" />
</apex:form>
    
</apex:page>

Hello Account (Ajax Toolkit)

Ajax Toolkit で Hello Account。

<apex:page >

<script src="/soap/ajax/31.0/connection.js" type="text/javascript"></script>
<script src="/soap/ajax/31.0/apex.js" type="text/javascript"></script>  

<script type="text/javascript">
  function getAccounts() {
    sforce.connection.sessionId = "{!$Api.Session_ID}";
    var accounts = sforce.connection.query("SELECT Id, Name FROM Account").getArray("records");
    for (var i = 0; i < accounts.length; i++) {
      console.log(accounts[i].Id, accounts[i].Name);
    }
  }
</script>

<apex:form >
    <apex:commandButton value="hello" onclick="getAccounts();"/>
</apex:form>

</apex:page>

Hello Account (Apex and Visualforce)

Apex と Visualforce で Hello Account。

public with sharing class HelloAccountController {

  public List<Account> acctList {get; set;}

  public PageReference getAccounts() {
    acctList = [SELECT Id, Name FROM Account];
    return null;
  }
}
<apex:page controller="HelloAccountController">
    
    <apex:form >
        <apex:commandButton value="hello" action="{!getAccounts}" rerender="dtb" />
    </apex:form>
    
    <apex:dataTable var="acct" value="{!acctList}" id="dtb">
        <apex:column value="{!acct.Id}" />
		<apex:column value="{!acct.Name}" />
    </apex:dataTable>
    
</apex:page>

デプロイに伴うテストの実行時間

デプロイに伴う RunAllTest で、各単体テストでどの程度時間を要したかを確認するには、Workbench から確認するのが、最も簡単。

  1. [utilities] | [Metadata API Process Status] で移動
  2. “AsyncProcessId” に 09Sxxxxxxxxxxxx のような RequestId を入力
  3. $ ant deploy
    Buildfile: /home/user/deploy/build.xml
    
    deploy:
    [sf:deploy] Request for a deploy submitted successfully.
    [sf:deploy] Request ID for the current deploy task: 09Sxxxxxxxxxxxx
    [sf:deploy] Waiting for server to finish processing the request...
    [sf:deploy] Request Status: Pending
    ...
    
  4. “Async Operation” に “Deploy” を選択し、”Get Status” を実行

デプロイが完了するまではポーリングし、完了すると結果が表示される。runTestResult.successes.<TestClass.TestMethod>.time が時間(ms)となる。

20140503_cap1


API で取得したい場合は、Metadata APIDeployResult.DeployDetails.RunTestsResult.RunTestSuccess.time で辿ると見える。

checkDeployStatus(asyncResultId, true)
getDetails()
getRunTestResult()