/** Prepares the list */
 public void prepare() throws Exception {
   ActionContext context = ActionContext.getContext();
   Map<String, Object> session = context.getSession();
   String local = (String) session.get("locale");
   this.statuses = callStatusService.getOptions(CallStatus.class.getSimpleName(), local);
   this.directions = callDirectionService.getOptions(CallDirection.class.getSimpleName(), local);
   this.reminderOptions =
       reminderOptionService.getOptions(ReminderOption.class.getSimpleName(), local);
   // Gets reminder email template list
   String hql =
       "select new EmailTemplate(id,name) from EmailTemplate where type = 'callRemind' order by created_on";
   reminderTemplates = emailTemplateService.findByHQL(hql);
 }
  /**
   * Saves entity field
   *
   * @return original call record
   * @throws ParseException
   */
  private Call saveEntity() throws Exception {
    Call originalCall = null;
    if (call.getId() == null) {
      UserUtil.permissionCheck("create_call");
    } else {
      UserUtil.permissionCheck("update_call");
      originalCall = baseService.getEntityById(Call.class, call.getId());
      call.setContacts(originalCall.getContacts());
      call.setLeads(originalCall.getLeads());
      call.setUsers(originalCall.getUsers());
    }

    CallDirection direction = null;
    if (directionID != null) {
      direction = callDirectionService.getEntityById(CallDirection.class, directionID);
    }
    call.setDirection(direction);
    CallStatus status = null;
    if (statusID != null) {
      status = callStatusService.getEntityById(CallStatus.class, statusID);
    }
    call.setStatus(status);
    ReminderOption reminderOptionEmail = null;
    if (reminderOptionEmailID != null) {
      reminderOptionEmail =
          reminderOptionService.getEntityById(ReminderOption.class, reminderOptionEmailID);
    }
    call.setReminder_option_email(reminderOptionEmail);
    EmailTemplate reminderTemplate = null;
    if (reminderTemplateID != null) {
      reminderTemplate =
          emailTemplateService.getEntityById(EmailTemplate.class, reminderTemplateID);
    }
    call.setReminder_template(reminderTemplate);
    User user = null;
    if (this.getAssignedToID() != null) {
      user = userService.getEntityById(User.class, this.getAssignedToID());
    }
    call.setAssigned_to(user);
    User owner = null;
    if (this.getOwnerID() != null) {
      owner = userService.getEntityById(User.class, this.getOwnerID());
    }
    call.setOwner(owner);
    SimpleDateFormat dateFormat = new SimpleDateFormat(Constant.DATE_TIME_FORMAT);
    Date start_date = null;
    if (!CommonUtil.isNullOrEmpty(startDate)) {
      start_date = dateFormat.parse(startDate);
    }
    call.setStart_date(start_date);

    String relatedObject = call.getRelated_object();
    if ("Account".equals(relatedObject)) {
      call.setRelated_record(relatedAccountID);
    } else if ("CaseInstance".equals(relatedObject)) {
      call.setRelated_record(relatedCaseID);
    } else if ("Contact".equals(relatedObject)) {
      call.setRelated_record(relatedContactID);
    } else if ("Lead".equals(relatedObject)) {
      call.setRelated_record(relatedLeadID);
    } else if ("Opportunity".equals(relatedObject)) {
      call.setRelated_record(relatedOpportunityID);
    } else if ("Target".equals(relatedObject)) {
      call.setRelated_record(relatedTargetID);
    } else if ("Task".equals(relatedObject)) {
      call.setRelated_record(relatedTaskID);
    }
    super.updateBaseInfo(call);
    return originalCall;
  }