The Universal Item Interface
The apex.item API provides a consistent way to get, set, show, hide, enable, disable, and validate any APEX page item regardless of its type.
Getting and Setting Values
var name = apex.item("P10_CUSTOMER_NAME").getValue();
apex.item("P10_STATUS").setValue("APPROVED");
apex.item("P10_STATUS").setValue("APPROVED", null, true); // suppress change event
apex.item("P10_SEARCH").setValue(""); // clear
Show, Hide, Enable, Disable
apex.item("P10_INTERNAL_NOTES").hide();
apex.item("P10_INTERNAL_NOTES").show();
apex.item("P10_STATUS").disable();
apex.item("P10_STATUS").enable();
if (apex.item("P10_STATUS").isDisabled()) { /* ... */ }
Working With Select Lists and Checkboxes
var displayText = apex.item("P10_DEPT_ID").displayValueFor(
apex.item("P10_DEPT_ID").getValue()
);
var selectedValues = apex.item("P10_ROLES").getValue(); // "ADMIN:EDITOR"
var valuesArray = selectedValues.split(":");
Showing Inline Validation Errors
if (apex.item("P10_EMAIL").isEmpty()) {
apex.message.showErrors([{
type: "error", location: ["page","inline"],
pageItem: "P10_EMAIL", message: "Email is required"
}]);
return false;
}
apex.message.clearErrors();
Setting Focus
apex.item("P10_EMAIL").setFocus();
setTimeout(function() { apex.item("P10_EMAIL").setFocus(); }, 100);
Timing Gotcha
If you call apex.item before the page is rendered, the item may not exist. Use Dynamic Actions or $(document).ready(). For items inside lazy-loaded regions, wait until the region renders.