I would like to ask if it is possible to sort the data sheet with one row but from a modified sort. The sorting should be
- Empty cells
- Accepted
- In Progress
- For Follow up
This is the custom order we need. These options are from a dropdown on the spreadsheet. How can I do this on google scripts for google spreadsheet? Thanks in advance
EDIT: Here is my code below:
var s = SpreadsheetApp.getActiveSheet();
var ss = SpreadsheetApp.getActiveSpreadsheet();
var currentRow = e.range.getRow();
var archiverow = e.source.getSheetByName("Archive").getLastRow();
Logger.log(archiverow)
Logger.log(currentRow)
var new_id = archiverow + currentRow
var id = "AR-"+new_id;
Logger.log(id);
var name = e.namedValues["Your Name"];
SendAdminSlack(e, name);
var duedate = e.namedValues["Due Date"].toString();
s.getRange(currentRow, 13).setValue(duedate);
duedate = Utilities.formatDate(new Date(duedate), "GMT+8", "MMMMM dd, yyyy");
var date_submitted = s.getRange(currentRow, 2).getValue().toString().split(' ');
date_submitted = date_submitted[1] + " " + date_submitted[2] + " " + date_submitted[3];
date_submitted = Utilities.formatDate(new Date(date_submitted), "GMT+8", "MMMMM dd, yyyy");
var sum = s.getRange(currentRow, 3).getValue();
var description = e.namedValues["Request Description"];
var ovcalendar = CalendarApp.getCalendarById(calendarId);
var title = '[ADMIN REQUEST] ' + name;
var caldesc = "Summary: " + sum + "\n";
caldesc += "Due Date: " + duedate + "\n\n";
caldesc += "Description: " + description;
Logger.log(caldesc);
var event = ovcalendar.createAllDayEvent(title, new Date(duedate), {description: caldesc});
Logger.log(date_submitted.toString())
s.getRange(currentRow, 14).setValue(event.getId().toString())
s.getRange(currentRow, 1).setValue(id);
var subj = "Admin Request for "+name;
var message = "Request Id: "+id+"<br>";
message += "Due Date: "+duedate+"<br>";
message += "Request Summary: "+sum+"<br><br>";
message += "Request Description: "+description;
MailApp.sendEmail({
to: kath,
subject: subj,
htmlBody: message,
noReply: true
});
s.sort(9); // I NEED TO CUSTOMIZE THIS SORT OR MAKE A NEW ONE
I need to sort it specifically on the order above the code.
generically sorting an array by specific value:
All typed on a phone so consider it pseudocode in the main