LoginSignup
3
4

More than 5 years have passed since last update.

remoteObjectsのサンプル (OrderBy指定)

Last updated at Posted at 2014-08-08

商談情報を取得するRemoteObject処理のサンプルです。
最初にapex:remoteObjectsを宣言します。

<apex:remoteObjects >
    <apex:remoteObjectModel name="Opportunity" fields="Name,Id">
        <apex:remoteObjectField name="Amount" />
        <apex:remoteObjectField name="IsPrivate" />
    </apex:remoteObjectModel>
</apex:remoteObjects>

JavaScript側はこんな感じです。

<script type="text/javascript">  
function drawPieChart() {
    // SObjectModel宣言
    var opportunityObject = new SObjectModel.Opportunity();

    // RemoteObject処理実行
    opportunityObject.retrieve({
        orderby: [{Amount: 'DESC'}],
        limit: 5
    },function(err, results) {
        if(err) {
            alert(err.message);
        } else {
            // 取得したリストをループ   
            results.forEach(function(result) {
                console.log(result.get('Name'));
                console.log(result.get('Amount'));
                console.log(result.get('IsPrivate'));
            });
        }
    });
}
</script>

値は「.get()」で取得できます。
orderbyで複数項目指定したい場合は、「orderby: [{Amount: 'DESC'},{Name: 'ASC'}]」という感じです。

3
4
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
4