Trimite e-mail pentru fiecare proprietar de proiect, inclusiv toate notele și subactivități

0

Problema

Am încercat să scrie un Appscript/Javascript care poate potrivi un proiect pentru sarcinile sale și note de relație. Apuca toate sarcinile + note pentru fiecare proiect și e-mail-proprietar al proiectului. Im nu sunt sigur cum să facă acest lucru la toate. Din moment ce acestea sunt în trei diferite foi.

Acum am un script pentru a trimite e-mailuri Săptămânal pentru fiecare persoane sarcinile care le sunt atribuite, care funcționează, deoarece este nevoie doar de un singur IPTM_Task foaie.

Foaie de calcul meu se pare ca asta Sarcini: Sarcina Foaie

enter image description here

Subactivități: Subactivități

enter image description here

Note: Note

enter image description here

Script-ul la e-mail sarcina proprietarilor

function sendEmails() {

  let s = '';
  const sh = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("ITPM_Tasks");
  const lastRow = sh.getLastRow();
  const startRow = 2; // First row of data to process
  const numRows = lastRow - 1; // Number of rows to process
  const rg = sh.getRange(startRow, 3, numRows, 6);
  const vs = rg.getValues();
  let oners = {pA:[]};
  vs.forEach((r,i) => {
    let [name,desc,status,owner,due] = r;
    if(status != 'Complete') {
     if(!oners.hasOwnProperty(owner)) {
       oners[owner]=[];
       oners[owner].push(r);
       oners.pA.push(owner)
     } else {
       oners[owner].push(r);
     }
    }
  });

  let subject = 'Weekly Reminder: The following tasks are assigned to you.';
  oners.pA.forEach(p => {
     let msg = `These Tasks below are assigned to you:\n`


    oners[p].forEach((r,i) => {
      let [name,desc,status,owner,due] = r;
        msg += `Task - ${i+1}\n`;
        msg += `Description: ${desc}\n`;
        msg += `Due Date: ${due.toDateString()}\n\n`
    });

    msg += `some message to task owners`;

MailApp.sendEmail(oners[p][0][3], subject, msg);
  });
}

EDIT:

  • Practic, mi-ar place script-ul pentru a vedea ID-ul de Proiect pe Task Sheet apuca numele proiectului (Proiect) și Proprietarul Apoi găsiți cele legate de "Subactivitate" Proiect Nume" și conexe "Note" pentru că numele proiectului

și trimite titularului de Proiect un e-mail cu Nume Proiect Subtask 1 subactivitate 2... Nota 1 Nota 2 idealoutput

1

Cel mai bun răspuns

0

Are sens să-l rupe în jos, e.g.astfel:

const ss = SpreadsheetApp.getActive()
const projects = ss.getSheetByName("Task Sheet").getDataRange().getValues()

projects.forEach( project => {
  const projectId = project[0]
  const status = project[2]

  if( status.toLowerCase() == "completed") return

  const notes = getNotesByProjectId(projectId)
  const subtasks = getSubtasksByProjectId(projectId)

  // here you can build your message
  let message = ""

  notes.forEach( note => {
    // add conditions here
    message += note[2] + "\n"
  })

  subtasks.forEach( subtask => {
    // add conditions here
    message += subtask[3] + "\n"
  })

  // and then send it

  
})

function getNotesByProjectId( projectId ){
  const allNotes = ss.getSheetByName("Notes").getDataRange().getValues()
  // Filter where Column 2 (index 1) is the project
  const filteredNotes = allNotes.filter( note => note[1] == projectId )
  return filteredNotes 
}

function getSubtasksByProjectId( projectId ){
  const allNotes = ss.getSheetByName("Subtasks").getDataRange().getValues()
  // Filter where Column 3 (index 2) is the project
  const filteredNotes = allNotes.filter( note => note[2] == projectId )
  return filteredNotes 
}

Referință

2021-11-23 22:09:18

În alte limbi

Această pagină este în alte limbi

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