This is as far as I got till my boss got mad that I was taking it down now and again. Time for V2, thanks for the help!
var ss = SpreadsheetApp.getActiveSpreadsheet();
var s = ss.getActiveSheet();
var r = s.getActiveRange();
var c = s.getActiveCell();
var aRow = r.getRow();
var aCol = r.getColumn();
var sampleCol = 17;
var nameCol = 3;
var statusCol = 2;
var aSName = s.getName();
Logger.log(ss.getEditors());
Logger.log(aSName);
Logger.log(aRow);
Logger.log(aCol);
//////////////////////////////////////////////////////////////////////////////
function SampleFormUrl(U){
var colIndexU = U.range.getColumn();
var rowIndexU = U.range.getRow();
var daysSince = s.getRange(rowIndexU,25);
if( U.value == "Arrived" && colIndexU == sampleCol ){
daysSince.clear();
}else
{ if( U.value == "Send" && colIndexU == sampleCol ){
var formlinkCell = s.getRange(rowIndexU,26);
var forminfo = s.getRange(rowIndexU,5,1,7);
var formSheet = ss.getSheetByName("Data");
var formInput = formSheet.getRange(11,2,1,9);
forminfo.copyValuesToRange(formSheet, 2, 9, 12, 12);
var formUrlRange = formSheet.getRange(6,1);
var formUrlCell = formUrlRange.getCell(1,1).getValue();
formlinkCell.setValue(formUrlCell);
U.range.setValue("Sent");
daysSince.setValue(0);
}
}
}
// this code is for generating the URLs for prefilled sample Forms
/////////////////////////////////////////////////////////////////
// This is for website lead submission movement handling
function websiteSubmit(W){
if( s.getName() == "External"){
Logger.log("External")
Logger.log(s.getName());
var rowIndexW = W.range.getRow();
var nameIt = "WebForm";
Logger.log(nameIt);
var leadRange = s.getRange(rowIndexW,1,1,24);
var targetPage = ss.getSheetByName(nameIt);
Logger.log(targetPage);
var lastRow = targetPage.getLastRow();
targetPage.insertRowAfter(lastRow);
leadRange.copyValuesToRange(targetPage,1,24,lastRow+1,lastRow+1);
var setRow = targetPage.getLastRow();
targetPage.getRange(setRow,statusCol).setValue("Even");
targetPage.getRange(setRow,4).setValue("LEJ WebForm");
}else
if(aSName == "Internal"){
var nameIt = s.getRange(aRow,nameCol).getValue();
Logger.log(nameIt);
var leadRange = s.getRange(aRow,1,1,24);
var targetPage = ss.getSheetByName(nameIt);
var lastRow = targetPage.getLastRow();
targetPage.insertRowAfter(lastRow);
leadRange.copyValuesToRange(targetPage,1,24,lastRow+1,lastRow+1);
}
}
// This is for website lead submission movement handling
////////////////////////////////////////////////////////////////
// This is the code for moving the info between lead sheets.
function leadProcessing(P){
if(nameCol == P.range.getColumnIndex()){
. Logger.log("Lead Processing");
var rowIndex = P.range.getRowIndex();
var nameIt = s.getRange(rowIndex,nameCol).getValue();
if (nameIt =="Open"||"Karim"||"Luke"||"James"||"Taryn"||"Wayne"||"Internal") {
Logger.log(nameIt);
var leadRange = s.getRange(rowIndex,1,1,24);
var targetPage = ss.getSheetByName(nameIt);
var lastRow = targetPage.getLastRow();
if(ss.getSheetName() != targetPage.getSheetName()){
. targetPage.insertRowAfter(lastRow);
leadRange.copyValuesToRange(targetPage,1,24,lastRow+1,lastRow+1);
var sheetChk = ss.getSheetByName("Internal");
var webSheeChk = ss.getSheetByName("External");
if(s.getSheetName() != sheetChk.getSheetName() && s.getSheetName() !webSheeChk.getSheetName()){
s.deleteRow(rowIndex);
var email = Session.getActiveUser().getEmail();
Logger.log(email);
var scriptProperties = PropertiesService.getScriptProperties();
scriptProperties.setProperties({
'Luke': 'Luke@com',
'James': 'Jamem@com',
'Taryn': 'Taryna@com',
'Wayne': 'Wayne@com',
'Karim': 'Karim'
});
var Email = scriptProperties.getProperty(nameIt);
Logger.log(Email);
var message = "Check your leads page you've been assigned a lead!";
var subject = "New Lead Assigned to you ! ";
GmailApp.sendEmail(Email, subject, message);
SpreadsheetApp.flush();
}
}
}
}
}
// T his is the code for moving the info between lead sheets.
////////////////////////////////////////////////////////////
// This is for Assigning Closed Accounts to the Accounts Manager
function leadAssignment(A){
if(statusCol == A.range.getColumn()&& A.value == "Assign"){
Logger.log("LeadAssignment")
var rowIndex = A.range.getRow();
var nameIt = A.getRange(rowIndex,nameCol).getValue();
var leadRange = s.getRange(rowIndex,1,1,24);
var targetPage = ss.getSheetByName(nameIt+"s Acct");
var lastRow = targetPage.getLastRow();
targetPage.insertRowAfter(lastRow);
leadRange.copyValuesToRange(targetPage,1,24,lastRow+1,lastRow+1);
if(s.getSheetName() != targetPage.getSheetName()){
s.deleteRow(rowIndex);
}
}
}
// This is for Assigning Closed Accounts to the Accounts Manager
////////////////////////////////////////////////////////////////
// This moves product to territory page
function leadConflict(C){
if(statusCol == s.getActiveRange().getColumn()){
Logger.log("Lead Conflict");
var rowIndex = s.getActiveRange().getRow();
var nameIt = s.getRange(rowIndex,statusCol).getValue();
var leadRange = s.getRange(rowIndex,1,1,24);
var targetPage = ss.getSheetByName(nameIt);
var lastRow = targetPage.getLastRow();
if(s.getSheetName() != targetPage.getSheetName()){
targetPage.insertRowAfter(lastRow);
leadRange.copyValuesToRange(targetPage,1,24,lastRow+1,lastRow+1);
s.deleteRow(rowIndex);
}
}
}
// This is for Assigning Closed Accounts to the Accounts Manager
////////////////////////////////////////////////////////////////
// This is for Applying a tiume stamp for edit to specific columns
function timeStamp(T){
var Colindex = aCol;
var row = T.range.getRow();
if( row > 2 && Colindex == 2||4||5||6||7||8||9||10||11||12||13||14||15||16||17||18||19||20||21){ //checks the column
>> var time = new Date();
ss.getRange('W' + row.toString()).setValue(time);
ss.getRange('X' + row.toString()).setValue(0);
}
}
// This is for Applying a tiume stamp for edit to specific columns
///////////////////////////////////////////////////////////////////
// Email handler