Salesforce REST Apiの /v38.0/limits/ をアクセスし、組織の制限を確認するVisualforceページです。 新規Visualforceページを作成しコードをコピーしたうえで、Visualforceタブを作成すれば使用できます。
<VFページ作成>
1.[設定]ー[カスタムコード]ー[Visualforce ページ] から、新規ボタンを押します
2.表示ラベル/名前:limitdisp (←なんでもよいです)
3.下のソースを貼り付けて保存
この状態で、「プレビュー」ボタンを押せば見れます
<タブ作成>
1.[設定]ー[ユーザーインターフェース]ー[タブ] から、Visualforce タブで「新規」
2.Visualforce ページ:limitdisp (上で名前を変えた場合はその名前)
タブの表示ラベル/タブ名:limitdisp
タブスタイル:任意
3.「次へ」とし、使用可能なプロファイル、表示アプリケーションを指定し「保存」
<Salesforce1モバイルアプリで見たい場合>
1.[設定]→[モバイル管理]→[Salesforce1ナビゲーション]でページを追加して下さい。
<apex:page docType="html-5.0" sidebar="false">
<apex:stylesheet value="//maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css"/>
<apex:includeScript value="//ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"/>
<script>
jQuery(document).ready(function($) {
$.ajax('/services/data/v38.0/limits',
{
beforeSend: function(xhr) {
// Set the OAuth header from the session ID
xhr.setRequestHeader('Authorization', 'Bearer {!$Api.Session_ID}');
},
success: function(json) {
var tbody = $('#tableData');
for(key in json) {
// alert(key + ":" + json[key].Remaining + ":" + json[key].Max);
var usage = json[key].Max-json[key].Remaining;
var ratio = (json[key].Max-json[key].Remaining)/json[key].Max*100;
if (ratio < 80) {
var color = "progress-bar-success";
} else if (ratio < 90) {
var color = "progress-bar-warning";
} else {
var color = "progress-bar-danger";
}
var td = $('<tr>')
.append('<td>' + key + '</td>')
.append('<td class="text-right">' + usage + '</td>')
.append('<td class="text-right">' + json[key].Max + '</td>')
.append('<td><div class="progress"><div class="progress-bar ' + color + '" role="progressbar" aria-valuemin="0" aria-valuemax="100" aria-valuenow="' + ratio + '" style="width:' + ratio + '%"></div></div></td></tr>')
tbody.append(td);
}
},
error: function(jqXHR, textStatus, errorThrown) {
// Oops - what went wrong?
alert(jqXHR.status + ': ' + errorThrown);
}
}
);
});
</script>
<h1>Org Limits</h1>
<table class="table table-condensed">
<thead>
<tr><th class="col-sm-6"></th><th class="text-right col-sm-2">Usage</th><th class="text-right col-sm-2">Max</th><th class="text-center col-sm-2">Percentage</th></tr>
</thead>
<tbody id="tableData">
</tbody>
</table>
</apex:page>