ईमेल भेजने के लिए प्रत्येक परियोजना के मालिक सहित सभी नोट्स और subtasks

0

सवाल

मैं कोशिश कर रहा हूँ लिखने के लिए एक Appscript/जावास्क्रिप्ट मेल कर सकते हैं कि एक परियोजना के लिए अपने कार्य और नोट्स का रिश्ता है । हड़पने सभी कार्यों + नोट्स प्रत्येक परियोजना के लिए और ईमेल के मालिक की परियोजना है । Im नहीं यकीन है कि यह कैसे करना है पर सभी. के बाद से वे कर रहे हैं तीन अलग अलग चादरें.

सही अब मैं एक स्क्रिप्ट भेजने के लिए साप्ताहिक ईमेल के लिए प्रत्येक व्यक्तियों को उन्हें सौंपा कार्यों है कि काम करता है क्योंकि यह केवल की आवश्यकता है एक IPTM_Task शीट.

मेरे स्प्रेडशीट इस तरह दिखता है कार्यों: टास्क शीट

enter image description here

SubTasks: Subtasks

enter image description here

नोट्स: नोट

enter image description here

स्क्रिप्ट ईमेल करने के लिए कार्य मालिकों

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

संपादित करें:

  • मूल रूप से, मैं की तरह होता है, स्क्रिप्ट देखने के लिए इस परियोजना आईडी पर कार्य पत्रक ले लो परियोजना का नाम (परियोजना) और मालिक तो खोजने से संबंधित "SubTask" परियोजना का नाम" और संबंधित "नोट्स" के लिए है कि परियोजना का नाम

और भेज परियोजना के मालिक के साथ एक ईमेल परियोजना का नाम Subtask 1 subtask 2... नोट 1 नोट 2 idealoutput

1

सबसे अच्छा जवाब

0

समझ में आता है करने के लिए इसे तोड़ने के नीचे, ई । जी.इस तरह:

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 
}

संदर्भ

2021-11-23 22:09:18

अन्य भाषाओं में

यह पृष्ठ अन्य भाषाओं में है

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

इस श्रेणी में लोकप्रिय

लोकप्रिय सवाल इस श्रेणी में