Custom Control
From LongJump Support Wiki
Designer > Objects > {object} > Field > New Field > Display Type > Custom Control
A Custom Control is Component or Page that displays in the GUI.
Types of Custom Controls
There are two types of Custom Controls:
- Component
- Components are created using HTML and JavaScript. Template variables are used to access record data.
Learn more: Components - Page
- Pages are built using HTML and Java. The request object is used to get the objectId and recordId, and additional APIs are used to get record data.
Using a Page as a Custom Control
When a JSP Page is launched from a context that is associated with a particular object record, the request object available in the JSP page contains the identifiers needed to obtain additional information from the record, using either the REST record Resource or the Java record handling APIs.
To get all of the parameters available in the request object, and their values:
<% String[] params = request.getParameterValues(); for (int i=0; i<params.length; i++) { String paramName = params[i]; String paramValue = request.getParameter( paramName ); } %>
To obtain a record identifier from a request object sent by the platform:
- With the object ID and record ID, use the getRecord API to retrieve the record.
<% String object_id = request.getParameter("object_id"); String record_id = request.getParameter("record_id"); %>
To obtain a record identifier from a request object sent by a Custom Action button:
- A Custom Action button can be applied to one record, or it can be applied to several records at one time if the user took advantage of the More Actions feature in the record list view.
- This code gets the record IDs and uses the searchRecords API to retrieve the records:
<% // Get the object ID and the comma separated list of record IDs String object_id = request.getParameter("object_id"); String selectedRecords = request.getParameter("selectedRecords"); // Break the comma-separated list into record IDs. // Join them with "OR" operands for use when searching for the records String filterCriteria = ""; if (selectedRecords != null) { StringTokenizer st = new StringTokenizer(selectedRecords,","); while (st.hasMoreTokens()) { if ( !"".equals(filterCriteria.trim())) { // Criteria string isn't empty, and we're adding another expression // Prefix the new expression with a boolean OR operator filterCriteria += " OR " } filterCriteria += "record_id = "+ st.nextToken(); } } // Use the filter criteria to fetch the selected records // Here, we ask for the record_id and name fields Result results; results = Functions.searchRecords(object_id , "record_id,name", filterCriteria); int resultCode = results.getCode(); if (resultCode < 0) { // Error occurred } else if (resultCode == 0) { // No records found. (This situation should never occur.) } else { // Records retrieved successfully // Process them here ParametersIterator iterator = results.getIterator(); while(iterator.hasNext()) { Parameters params = iterator.next(); String recordID = params.get("record_id"); String recordName = params.get("name"); // Take additional action according to your business logic } } %>