I have a sppreadsheet with many rows, in each row - cell with status in second column for example: a010111101001 and about 30 more statuses. In scripts I have functions named the same like status cell. All I want is one function, that call all other functions based on active status cell. Now I have only function, that get name of the script from active cel, and will be very grateful if you can help me. Here is code that i have:
function nameoffunc() {
var ss = SpreadsheetApp.getActiveSpreadsheet().getSheetByName('123')
var row = ss.getActiveCell().getRow();
var status = ss.getRange(row, 2).getValue();
//value from status - is the name of function
//I search way to do something like this:
//run.scrpt(status);
}
Update: In status variable - value "a00110000000000000"
function a00110000000000000(){
var ss1 = SpreadsheetApp.getActiveSpreadsheet().getSheetByName('123')
var result = ss1.getRange("C35");
result.setValue(22)
}
function nameoffunc() {
var ss = SpreadsheetApp.getActiveSpreadsheet().getSheetByName('123')
var row = ss.getActiveCell().getRow();
var status = ss.getRange(row, 2).getValue();
var a = {
"u2": function(){return status;},
"as": function(){return "eft";}
};
Logger.log(a["u2"]());
}
Update: Thank you @daniel ! The way to run scripn by name from spreadsheet cell is:
function nameoffunc() {
var ss = SpreadsheetApp.getActiveSpreadsheet().getSheetByName('123')
var row = ss.getActiveCell().getRow();
var status = ss.getRange(row, 2).getValue();
var a = {
"a00110000000000000": function(){
var ss1 = SpreadsheetApp.getActiveSpreadsheet().getSheetByName('123')
var result = ss1.getRange("C35");
result.setValue(22)
},
"as": function(){return "eft";}
};
Logger.log(a[status]());
}