Brekeke Contact Center Suite Wiki

CRM - Push Call Lists

Requirements

Brekeke CRM v.2.7.8.0.15457 or later

 

About Web-If API (only some part are translated to English)

http://www.brekeke-sip.com/download/ccs/crm_2_7_5_web_if_v140_190906_en.odt

 

Steps
  • Create a new script as “calllist” from the Tenant menu > [Script] page.
  • Copy & paste the entire text from the script_calllist.txt and save.
  • Download the webif.zip file, then extract the webif.html file from the downloaded file.
  • Place the webif.html under webapps/crm folder on the server.
  • Open https://xxxxx/crm/webif.html with the browser and fill the fields like below;
    • URL – https://xxx/crm/adminif.action
    • Tenant, User, Pass – Account information of a tenant administrator
    • Project ID – The project ID (number) to which you want to import the list. (See below “How to check the project ID”)
    • Script – calllist
    • Function — upload
    • Params — Json array of a string value
      • 1 – ‘$project‘ (to pass the project object to the function.)
      • 2 – options. To change the priority, set “{“changePriority”:true}
      • 3 – columns. Json array of field ID. (Not field names, please check the field ID from the Workspace > Customer > Field Settings page.)
      • 4 – data. Json array of an array of import data.
[ "$project","{\"changePriority\":true}",
 "[\"telno1\",\"telno2\",\"telno3\",\"email\",\"firstname\",\"lastname\",\"priority\"]",
 "[[\"2501111104\",\"\",\"2501111100\",\"user1@brekeke.com\",\"User1\",\"\",\"Low\"],
[\"2501111105\",\"\",\"2501111100\",\"user2@brekeke.com\",\"User2\",\"\",\"Low\"],
[\"2501111106\",\"\",\"2501111100\",\"user3@brekeke.com\",\"User3\",\"\",\"High\"]]" 
]

To change the priority

Create a field with the field ID “property” in the field settings.

 

How to check the project ID

Go to the Workspace > Project page to see the project list. Mouseover on the project name at the bottom of the browser (Chrome or Firefox) and the link “javascript:window.parent.window.sel_pj_func(‘27‘,’p1’)” should appear. In this example, 27 is the project ID.

 

script_calllist.txt:
var BaseTenant = Java.type('jp.brekeke.common.business.BaseTenant');
var log = Java.type('jp.brekeke.common.common.BaseLog').getMyLogger();
var HashMap = Java.type('java.util.HashMap');
var ArrayList = Java.type('java.util.ArrayList');
var Timestamp = Java.type('java.sql.Timestamp');
var Date = Java.type('java.util.Date');
var SoManager = Java.type('com.brekeke.crm.common.SoManager');
var MapA = Java.type('java.util.Map[]');
function getTstamp(manager, tenant_name, project_id, mxmn) {
  var sql =
    'SELECT ' +
    mxmn +
    '(cl.dialer_tstamp) tstamp FROM `' +
    'm_project_calllist_' +
    tenant_name +
    '_' +
    project_id +
    '` cl WHERE cl.process_mode=0';
  var con = null;
  var stm = null;
  var ret = null;

  try {
    con = manager.getJdbcOptions().getConnection();
    stm = con.createStatement();
    var rs = stm.executeQuery(sql);
    if (rs.next()) {
      ret = rs.getTimestamp(1);
    } else {
      log.error('Failed to get tstamp:' + sql);
    }
    rs.close();
    return ret;
  } finally {
    if (stm) {
      stm.close();
    }
    if (con) {
      con.close();
    }
  }
}
/*
  columns - Array of the column names
  data - Array of the arrays of import data
*/

function upload(project, options, columns, data) {
  options = options ? JSON.parse(options) : null;
  columns = JSON.parse(columns);
  data = JSON.parse(data);
  var manager = SoManager.instance;
  var tenant_name = project.getTenant_name();
  var project_id = project.getProject_id();
  var change_priority = false;
  if (options) {
    if (options.changePriority) {
      change_priority = true;
    }
  }

  var maxTstamp = null;
  var minTstamp = null;

  if (change_priority) {
    maxTstamp = getTstamp(manager, tenant_name, project_id, 'max');
    minTstamp = getTstamp(manager, tenant_name, project_id, 'min');
    maxTstamp = new Timestamp(maxTstamp.getTime() + 1000);
    maxTstamp = maxTstamp.toString();
    maxTstamp = maxTstamp.replaceAll('-', '/').substring(0, 19); // 2022/02/08 21:20:00
    log.info(maxTstamp);
    minTstamp = new Timestamp(minTstamp.getTime() - 1000);
    minTstamp = minTstamp.toString();
    minTstamp = minTstamp.replaceAll('-', '/').substring(0, 19);
  }

  var al = new ArrayList();
  for (var i = 0; i < data.length; i++) {
    var row = data[i];
    var hm = new HashMap();
    var max = row.length > columns.length ? columns.length : row.length;
    for (var c = 0; c < max; c++) {
      hm.put(columns[c], row[c]);
      if (change_priority && columns[c] == 'priority') {
        if (row[c] == 'High') {
          hm.put('dialer_tstamp', minTstamp);
        } else {
          hm.put('dialer_tstamp', maxTstamp);
        }
      }
    }
    al.add(hm);
  }

  var ary = new MapA(al.size());
  al.toArray(ary);
  var errorContinue = true;
  if (options) {
    if (options.errorContinue === false || options.errorContinue === 'false') {
      errorContinue = false;
    }
  }

  var res = project.importCall(ary, errorContinue);
  var em = '';
  var e = res.getErrorMessages();
  if (e.size() > 0) {
    em = ',first_error=' + e.get(0);
  }
  return (
    'OK:success=' + res.getSuccess() + ',errCount=' + res.getErrorCnt() + em
  );
}

 

Download: webif.html (webif.zip)>>

 

Yes No
Suggest Edit