ucAddInit is called as the Add routine is first entered. This method can be used to provide processing before the add issue screen is launched.
Add Issue screen
public void ucAddInit(SesameSession session, // contains values of form elements HashMap values) // selected Vals hashmap
The business rule directive <== load ==> in conjunction with the SCREEN_NAME equaling ADD provides a similar opportunity to influence the add screen before it is loaded.
<== load ==>
if (SCREEN_NAME = 'ADD') {
FIELD_NAME = VALUE;
}
This example shows how to set the values of data on the form after reading data from the both the current user and that user's manager's account. This will happen before the add issue screen is entered, thus pre-populating the "Manager's Work Phone" and "Manager's Cell Phone" fields, depending upon the user accessing the screen.
public void ucAddInit(SesameSession session, // contains values of form elements HashMap values) // selected Vals hashmap { // Call Business Rules super.ucAddInit(session, values); // Get area & project String areaId = (String) values.get("AREA"); String projectId = (String) values.get("PROJECT"); projectId = projectId.substring(projectId.indexOf("|") + 1, projectId.length()); Z.log.writeToLog(Z.log.WARN, "UC: ucAddInit - areaId=" + areaId + ", projectId=" + projectId); // Check for specific area & project if (A_CUSTOMER_ISSUES.equals(areaId) && P_CUSTOMER_ISSUES_DATA.equals(projectId) ) { Connection dbConn = null; SecurityUser originator = null; SecurityUser manager = null; String wPhone = null; String cPhone = null; try { // Get database connection dbConn = Z.pool.getConnection("ucAddInit"); // Lookup originator's manager User ID, // which is stored in the account USER_DEFINED_1 field originator = SecurityUser.getReference(dbConn, session.getUserId()); manager = SecurityUser.getReference(dbConn, originator.getUserField1()); // If manager's account found, get work and cell phone info if (manager != null) { wPhone = manager.getWorkTelephone(); cPhone = manager.getCellPhone(); } Z.log.writeToLog(Z.log.WARN, "UC: ucAddInit - wPhone=" + wPhone + ", cPhone=" + cPhone); // Set form data values.put("MANAGER_WORK_PHONE", wPhone); values.put("MANAGER_CELL_PHONE", cPhone); } catch (Exception e) { Z.log.writeToLog(Z.log.ERROR, "UC: ucAddInit Exception: " + e); ErrorWriter.write(e, ErrorWriter.LOGERR); } finally { // Close the database connection if (dbConn != null) { Z.pool.close(dbConn); } } } }