function EstimateUpload() {
// get all sheet IDs
var spreadsheet = SpreadsheetApp.getActive();
var currentSpreadSheetId = spreadsheet.getId()
var Datasheet = spreadsheet.getSheetByName("Data Sheet");
var SpreadsheetOfProposalDatabase = SpreadsheetApp.openById("xxx");
var SheetOfSpreadsheetOfProposalDatabase = SpreadsheetOfProposalDatabase.getSheets()[0];
// get data from data sheet
var cellvalue = "";
var cell
var values=[currentSpreadSheetId];
var i;
for (i = 4; i <500; i++) {
cell= "B"+i
cellvalue = Datasheet.getRange(cell).getDisplayValue()
values.push(cellvalue)
}
Logger.log(values);
Logger.log(values.length)
// Appends a new row with 3 columns to the bottom of the
// spreadsheet containing the values in the array
var ClientName = Datasheet.getRange("B4");
var ProjectName = Datasheet.getRange("B5");
var docuploadedstatus = Datasheet.getRange("B1262");
if(ClientName.isBlank()||ProjectName.isBlank()){
Browser.msgBox('Information missing ',"Please make sure to enter Client name as well as Project Name first",Browser.Buttons.OK);
}else{
if(docuploadedstatus.isBlank()){
// check if row estimate was previously uploaded and if so, return row number
function rowOfEmployee(){
var sheet = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet();
var data = SheetOfSpreadsheetOfProposalDatabase.getDataRange().getValues();
for(var i = 0; i<data.length;i++){
if(data[i][0] == currentSpreadSheetId){ //[1] because column B
return i+1;
}
}
}
var rownumber= rowOfEmployee()
Logger.log("entry in row number: "+rownumber)
if(rownumber==null){
SheetOfSpreadsheetOfProposalDatabase.appendRow(values);
}else{
SheetOfSpreadsheetOfProposalDatabase.deleteRow(rownumber);
SheetOfSpreadsheetOfProposalDatabase.appendRow(values);
}
// set values in checking column
var valuestopaste = [ ];
for(i=0; i <values.length; i++){
valuestopaste.push([values[i]])}
var range = Datasheet.getRange("C3:C499");
Logger.log(valuestopaste);
range.setValues(valuestopaste);
Datasheet.getRange('B1262').activate();
Datasheet.getCurrentCell().setValue("uploaded");
Datasheet.hideSheet();
fixingrates()
setEditors()
Fixingsheet()
}else{ Browser.msgBox('Good news: sheet was already uploaded ',"Sheet is already available for reporting; treat yourself to a coffee :) ",Browser.Buttons.OK);
};
};
};
function AddDeliverableAndActivity() {
var spreadsheet = SpreadsheetApp.getActive();
var currentSpreadSheetId = spreadsheet.getId();
var SpreadsheetOfDeliverablesAndActivities = SpreadsheetApp.openById("xxx");
var SheetOfSpreadsheetOfDeliverablesAndActivities = SpreadsheetOfDeliverablesAndActivities.getSheets()[0];
var Datasheet = spreadsheet.getSheetByName("Data Sheet");
var NewActivity = Datasheet.getRange("B152");
SheetOfSpreadsheetOfDeliverablesAndActivities.appendRow([
"",NewActivity.getDisplayValue(),
]);
var responsemessage= NewActivity.getDisplayValue() + " has been added and can now and in future estimations be selected above"
Browser.msgBox('Done ',responsemessage ,Browser.Buttons.OK);
};
--
You received this message because you are subscribed to the Google Groups "Google Apps Script Community" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-apps-script-c...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-apps-script-community/02e9fac9-22c7-4f04-8741-4340db04b809o%40googlegroups.com.
Hey George,
Thanks for the response.
Here the process:
In google sheet 1: a person can complete an estimation and then make it available in sheet 2 for checking some details on it. The connection is made through a script that uploads the sheet 1 ID to a google sheet and then a importrange that imports that information into the 2nd sheet.
Important to note, the estimation in sheet 1 is then further adjusted, but the importrange function in sheet 2 makes sure the information in sheet 2 is always up to date. Hence, it is not just a submission.
Do you think this can be achieved in an easier way?
The current issue triggering the script to upload/sync the estimation, the user needs to authorize the script. After authorizing the user then needs to trigger the macro a second time which is not user-friendly and to some it is not clear.
Till