Slack BOT report, how to break data to report?

20 views
Skip to first unread message

ValeVale

unread,
Nov 7, 2022, 10:31:14 AM11/7/22
to Google Apps Script Community
Hey again dear community
As Scripts newbie I still need your help: How do I get my bot to break down and report the data to be found on the Metrics tab of my sheet? Specifically, I want both figures on "CR Disputed" and "CR to check" in my report. 

Here's the  script (will skip the block-payload script, that one is working - YAY) posting just the bit i need help with

function botCRcheck() {
const ss = SpreadsheetApp.getActive();
let data = ss.getSheetByName('Metrics Disputed CR').getRange("A3:B7").getValues();
let payload = buildAlert(data);
sendAlert(payload);
}
function buildAlert(data) {
let crTocheck = data [3][1]

And here's a copy of the sheet, check the "Metrics" tab. 
Many many thanks <3 


I was also interested in creating a Script to auto-clean the sheet with the processed requests, anyone can give me a hint on how to start building it?




ValeVale

unread,
Nov 22, 2022, 5:49:20 AM11/22/22
to Google Apps Script Community
Anyone can help me on this????

cwl...@gmail.com

unread,
Nov 22, 2022, 9:49:34 AM11/22/22
to Google Apps Script Community
Try something like this:
function buildAlert(data) {
//each data item must be declared
let crDisputed = data[0][1]    //row1, col2 of data
let crTocheck = data[1][1]     //row2, col2 of data

let payload = {
      "blocks": [
    {

...   skipped lines ...

      {
        "type": "section",
        "text": {
          "type": "plain_text",
          "text": "CRs Disputed :" + crDisputed + "\nCR tickets to check :"  + crTocheck,       //I am guessing the "\n" will work as a "new line" character
          "emoji": true 
        },
...

ValeVale

unread,
Nov 24, 2022, 11:33:37 AM11/24/22
to Google Apps Script Community
Thanks a bunch! That worked! And I also realized that I was not calling the right range from the data variable -_- Thanks again!!! 
Reply all
Reply to author
Forward
0 new messages