I'm pulling values from a textarea tag in html and trying to insert them into a column in google sheets
in order to make a contact list to use later. The user copy pastes from an excel column a list of phone numbers into the text area input.
(the sheet gets created)
Where am I going wrong
<script>
function createGroup() {
var number = document.getElementById('group').value;
var name = document.getElementById('groupName').value;
google.script.run.withSuccessHandler(groupCreated).newGroup(number, name);
return false;
}
</script>
This is the code.gs script (server side)
function newGroup(number, name){
var num = number;
//I need to format them to +155555555 format
var prefix = "+1";
var removeDashes = num.replace(/-/g,"");
var addPrefix = prefix + removeDashes;
var format = addPrefix.replace(/\n/g," +1");
var arr = format.split(" ");
var array = arr.slice(0);
var length = arr.length;
var sheetName = name;
var ss = SpreadsheetApp.openById('xxxxxxxxxxxxxxx')
var newSheet = ss.insertSheet(sheetName);
var activate = newSheet.activate();
var range = activate.getRange(1, 1, length);
range.setValues(array);
return "Done";
}