簡體   English   中英

循環鉛分配

[英]Round Robin Lead Assignments

我正在嘗試通過遍歷 AE 列表並將“X”移動到接下來應該分配的 AE 來將潛在客戶分配給客戶主管。 我確定是否應該為潛在客戶分配某人的方法是公司名稱旁邊是否有空白。

本質上邏輯應該是 go,找到空白,找到 X 旁邊的 AE 名稱,使用該名稱填寫空白,找到下一個空白,依此類推,直到沒有更多空白。 我已經寫出了偽代碼,但我對 Google App Scripts 一點也不熟悉。 有人可以幫我弄清楚哪些代碼適用於偽代碼嗎?

***
var STRINGX = 'X';
function main() {
  Logger.log(getNextPerson())
  var person = getNextPerson();
  var leadRow = findNextOpenLead();
  assignPersonToNextLead(person, leadRow);
  moveXDown();
}
function getNextPerson() {
  var sheet = SpreadsheetApp.getActiveSheet().getDataRange().getValues();
  var startRow = 2;
  var salesReps = sheet[1].splice(0, 1)
}
function moveXDown() {
  // find column with x and save it as a variable
  // delete x from that column
  // add 1 to  column we found 
  // put it in ^ that column
}
function assignPersonToNextLead(person, leadRow) {
  // find row next to lead 
  // put person in the b column and row of lead
}
function findNextOpenLead() {
  // go through column b until you find an open cell
  // use that row in column d to find the lead 
}
***

A、B、C 代替真實 AE 的名稱

客戶經理名單

公司名稱旁邊的空格

對線索列表進行循環分配

function roundRobinLeads() {
  const ss = SpreadsheetApp.getActive();
  const lsh = ss.getSheetByName('Round Robin Leads');
  const lvs = lsh.getRange(2, 1, lsh.getLastRow() - 1, lsh.getLastColumn()).getDisplayValues();
  const rsh = ss.getSheetByName('Round Robin');
  const rvs = rsh.getRange(2, 1, rsh.getLastRow() - 1, 2).getValues();
  let rr = { pA: [], index: 0, incr: function () { return this.index++ % this.pA.length; }, getIndex: function () { return this.index % this.pA.length; } };
  rvs.forEach((r, i) => {
    rr[r[1]] = r[0];
    rr.pA.push(r[1]);//push name in property array
    if (r[0]) {
      rr.index = i;//assign initial selection
      rsh.getRange(rr.index + 2, 1).setValue('');//remove x from current next
    }

  });
  lvs.forEach((r, i) => {if (!r[1]) {lsh.getRange(i + 2, 2).setValue(rr.pA[rr.incr()]);}});//assign lead and increment index
  rsh.getRange(rr.getIndex() + 2, 1).setValue('x');//record next assignment from rr.getIndex();
}

剩余百分比

我嘗試添加其他內容,但 Stack Overflows 愚蠢的內容檢查器將表格標記為格式不正確的代碼。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM