我剩下多少單位
在 SuiteScript 1.0 中,使用 nlobjContext.getRemainingUsage()
檢索剩餘單位。使用全域性 nlapiGetContext
函式檢索 nlobjContext
引用。
// 1.0
var context = nlapiGetContext();
nlapiLogExecution("DEBUG", "Governance Monitoring", "Remaining Usage = " + context.getRemainingUsage());
nlapiSearchRecord("transaction"); // uses 10 units
nlapiLogExecution("DEBUG", "Governance Monitoring", "Remaining Usage = " + context.getRemainingUsage());
在 SuiteScript 2.0 中,使用 N/runtime
模組的 Script
物件的 getRemainingUsage
方法。
// 2.0
require(["N/log", "N/runtime", "N/search"], function (log, runtime, s) {
var script = runtime.getCurrentScript();
log.debug({
"title": "Governance Monitoring",
"details": "Remaining Usage = " + script.getRemainingUsage()
});
s.load({"id":"customsearch_mysearch"}); // uses 5 units
log.debug({
"title": "Governance Monitoring",
"details": "Remaining Usage = " + script.getRemainingUsage()
});
});