循环导致的分配

0

的问题

我试图来分配会导致帐户管理人员通过循环,通过列表a-e和移动一个"X"为AE谁应该分配的下一步。 我确定如果导致应该分配的人是否有一个空白的下一个公司的名称。

基本的逻辑应该去,找空白,找到AE名称旁边的X,使用这个名字来填补空白,找到下一个空白,直至有没有更多的空白。 我已经写出伪但是我不熟悉的与谷歌的应用程序脚本。 有人可以帮我找出是什么代码将工作伪?

***
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的名字

列表中的账户管理人员的名字

坯下,以公司的名字

1

最好的答案

0

使循环作业到导致名单

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();
}

其余%

我试图添加其他内容,但堆溢出愚蠢的内容检查被举报表格式不正确的代码。

2021-11-24 00:45:05

谢谢你这么多! 这个完美的作品!
Chad Riorden

这将能够工作,如果有3个不同的列表中,将循环从基于标准的导致?
Chad Riorden

大概。 请提出一个想法在另一个问题
MiMi

其他语言

此页面有其他语言版本

Русский
..................................................................................................................
Italiano
..................................................................................................................
Polski
..................................................................................................................
Română
..................................................................................................................
한국어
..................................................................................................................
हिन्दी
..................................................................................................................
Français
..................................................................................................................
Türk
..................................................................................................................
Česk
..................................................................................................................
Português
..................................................................................................................
ไทย
..................................................................................................................
Español
..................................................................................................................
Slovenský
..................................................................................................................