Saya ingin mendapatkan data dari Sheet Melalui App Script

15 views
Skip to first unread message

Rahmadhani Novian Jaya

unread,
Oct 14, 2024, 6:59:09 AMOct 14
to Google Apps Script Community
Saya ingin mendapatkan data Sheet dari nomor 2 kebawah kemudian saya membuat App Script untuk automatic JIRA

Adapun source codenya :
function sendToJira() {
    var sheet = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet();
    var row = sheet.getActiveCell().getRow();
    var dataRange = sheet.getRange(2, 1, sheet.getLastRow() - 1, 17); // Mengambil data dari baris ke-2 dan kolom A sampai Q
    var description = sheet.getRange(row, 2).getValue(); // Deskripsi
       var data = dataRange.getValues();
    for (var i = 0; i < data.length; i++)
    var payload = {
        "fields": {
            "project": {
                "key": "ITSEC" // Ganti dengan kunci proyek Anda
            },
        "summary": row[1] ? row[1] : 'Default Summary',  // Menggunakan data dari kolom "Email Address" sebagai contoh
        "description": "Name: " + (row[2] ? row[2] : '') + "\n" +
                       "Position: " + (row[3] ? row[3] : '') + "\n" +
                       "Date of incident: " + (row[4] ? row[4] : '') + "\n" +
                       "Incident Type: " + (row[5] ? row[5] : '') + "\n" +
                       "Priority: " + (row[6] ? row[6] : '') + "\n" +
                       "Incident information details: " + (row[7] ? row[7] : '') + "\n" +
                       "Supporting evidence: " + (row[8] ? row[8] : '') + "\n" +
                       "Phone Number: " + (row[9] ? row[9] : '') + "\n" +
                       "The situation or condition before the incident occurred: " + (row[10] ? row[10] : '') + "\n" +
                       "Condition after the incident occurred: " + (row[11] ? row[11] : '') + "\n" +
                       "Loss or Damage Occurring: " + (row[12] ? row[12] : '') + "\n" +
                       "When did this incident happen? in WIB (GMT +7) time: " + (row[13] ? row[13] : '') + "\n" +
                       "What is the estimated total loss and damage that occurred?: " + (row[14] ? row[14] : '') + "\n" +
                       "Company Email: " + (row[15] ? row[15] : '') + "\n" +
                       "Employee ID: " + (row[16] ? row[16] : ''),
            "issuetype": {
                "name": "Task" // Ganti dengan tipe isu yang sesuai
            },
    "duedate": "2024-10-15",  // Tanggal jatuh tempo
    "labels": ["ITSEC_RedTeam"],  // Label yang diperlukan
    "customfield_10015": "2024-10-10"  // Tanggal mulai
  }
    };

    var options = {
        "method": "post",
        "contentType": "application/json",
        "headers": {
            "Authorization": "Basic " + Utilities.base64Encode("rahmadhani...@edot.id:ATATT3xFfGF05CSIwjQq11xwnLjDt11lg6e0vf6HypgVqs_KKjJ1yINo0jZdfoNOE5d6cIHkvwE5UVLp8QqE_kRjz9sjIYiRHICDBw7CW6UtGV33Raa0TYSXOoP9aM7CGh5WsjPPSL7H7CLijYO5mHIp4TNuRTCYSfFG7KNGBKp6LhvCcdm0S8U=39448FCF") // Ganti dengan email dan token API Anda
        },
        "payload": JSON.stringify(payload)
    };

    UrlFetchApp.fetch(url, options);
   
}


Nah untuk bisa mendapatkan data nya apakah yang bisa saya lakukan untuk perubahan codenya
Reply all
Reply to author
Forward
0 new messages