Message details Exception: The parameters (String) don't match the method signature for SpreadsheetApp.Sheet.getActiveRange.

252 views
Skip to first unread message

Jay Anne Otadora

unread,
Sep 8, 2023, 11:05:42 AM9/8/23
to Google Apps Script Community
Hi everybody, 

Im a beginner 
error message attachederror.jpg 
I encounter this message everytime I have to add a client information. 
The scipt would run and succesfully add the date into the secific sheet. 
however after the data is added the form should be clear. 
Please help. 
Here is my code below: 
function submitData(){
  var myGoogleSheet = SpreadsheetApp.getActiveSpreadsheet();
  var shUserForm = myGoogleSheet.getSheetByName("UserForm");
  var datasheet =myGoogleSheet.getSheetByName("JClientRecord");

  //create a instance of the user-interface environment o use the alert features
  var ui =SpreadsheetApp.getUi();

  var response=ui.alert("Submit","Do you want to submit data?", ui.ButtonSet.YES_NO);

  //checking the user response

  if(response==ui.Button.NO){return;// exit from this function
 }
  if(validateEntry()== true){
     var blankRow = datasheet.getLastRow()+1; //identify the next row.
   
    //code to  update the data in database sheet

    datasheet.getRange(blankRow,3).setValue(shUserForm.getRange("B1FName").getValue());//recording the B1FName
    datasheet.getRange(blankRow,4).setValue(shUserForm.getRange("B1MName").getValue());//recording the B1MName
    datasheet.getRange(blankRow,5).setValue(shUserForm.getRange("B1LName").getValue());//recording the B1LName
    datasheet.getRange(blankRow,20).setValue(shUserForm.getRange("B1MobileNumber").getValue());//recording the B1MobileNumber
    datasheet.getRange(blankRow,21).setValue(shUserForm.getRange("B1HomePhone").getValue());//recording the B1HomePhone
    datasheet.getRange(blankRow,7).setValue(shUserForm.getRange("B1Email").getValue());//recording the B1Email
    datasheet.getRange(blankRow,10).setValue(shUserForm.getRange("B1UnitNumber").getValue());//recording the B1UnitNumber
    datasheet.getRange(blankRow,11).setValue(shUserForm.getRange("B1StreetNumber").getValue());//recording the B1StreetNumber
    datasheet.getRange(blankRow,12).setValue(shUserForm.getRange("B1StreetName").getValue());//recording the B1StreetName
    datasheet.getRange(blankRow,13).setValue(shUserForm.getRange("B1StreetType").getValue());//recording the B1StreetType
    datasheet.getRange(blankRow,14).setValue(shUserForm.getRange("B1StreetDirection").getValue());//recording the B1StreetDirection
    datasheet.getRange(blankRow,15).setValue(shUserForm.getRange("B1City").getValue());//recording the B1City
    datasheet.getRange(blankRow,16).setValue(shUserForm.getRange("B1Province").getValue());//recording the B1Province
    datasheet.getRange(blankRow,17).setValue(shUserForm.getRange("B1Country").getValue());//recording the B1Country
    datasheet.getRange(blankRow,18).setValue(shUserForm.getRange("B1Postal").getValue());//recording the B1Postal
     datasheet.getRange(blankRow,19).setValue(shUserForm.getRange("B1BirthDate").getValue());//recording the B1BirthDate
    datasheet.getRange(blankRow,25).setValue(shUserForm.getRange("MaritalStatus").getValue());//recording the MaritalStatus
    datasheet.getRange(blankRow,42).setValue(shUserForm.getRange("B1Spouse").getValue());//recording the B1Spouse
    datasheet.getRange(blankRow,78).setValue(shUserForm.getRange("CallAnswered").getValue());//recording the CallAnswered
    datasheet.getRange(blankRow,79).setValue(shUserForm.getRange("CallDate").getValue());//recording the CallDate
    datasheet.getRange(blankRow,80).setValue(shUserForm.getRange("Validated").getValue());//recording the Validated
    datasheet.getRange(blankRow,81).setValue(shUserForm.getRange("Consider").getValue());//recording the Consider
    datasheet.getRange(blankRow,82).setValue(shUserForm.getRange("notes").getValue());//recording the notes
     
     //getting Contact Id and recording the Whole name
     var B1FName = shUserForm.getRange("B1FName").getValue();
     var B1MName = shUserForm.getRange("B1MName").getValue();
     var B1LName = shUserForm.getRange("B1LName").getValue();
     datasheet.getRange(blankRow,2).setValue(B1FName+B1MName+B1LName);//recording the ContactId
     datasheet.getRange(blankRow,6).setValue(B1FName+" "+B1MName+" "+B1LName);//recording the Recording the Whole Name
 
   
    //getting Whole Address
    var B1UnitNumber = shUserForm.getRange("B1UnitNumber").getValue();// declaring the the B1UnitNumber
    var B1StreetNumber = shUserForm.getRange("B1StreetNumber").getValue();// declaring the B1StreetNumber
    var B1StreetName = shUserForm.getRange("B1StreetName").getValue();// declaringthe B1StreetName
    var B1StreetDirection = shUserForm.getRange("B1StreetDirection").getValue();// declaring the B1StreetDirection
    var B1StreetType = shUserForm.getRange("B1StreetType").getValue();// declaring the B1StreetType
    var B1City = shUserForm.getRange("B1City").getValue();// declaring the B1City
    var B1Province = shUserForm.getRange("B1Province").getValue();// declaring the B1Province
    var B1Country = shUserForm.getRange("B1Country").getValue();// declaring the B1Country
    var B1Postal = shUserForm.getRange("B1Postal").getValue();// declaring the B1Postal
    datasheet.getRange(blankRow,9).setValue(B1UnitNumber+" "+B1StreetNumber+" "+B1StreetName+" "+B1StreetType+ " "+B1StreetDirection+" "+B1City+" "+B1Province+" "+B1Country+" "+B1Postal);
 


   
   
     //code to update the date and time and user
    datasheet.getRange(blankRow,138).setValue(new Date()).setNumberFormat('yyyy-mm-dd h:mm:ss');//recording the notes
    datasheet.getRange(blankRow,136).setValue(Session.getActiveUser().getEmail());//recording the notes

    ui.alert(' "New Data Saved - Emp#' + shUserForm.getActiveRange("ContactId").getValue()+ '"');

     //clearing the form
     shUserForm.getRange("AssignedUSer").clear(); //Assigned USer
     shUserForm.getRange("AssignedAssistant").clear(); //Assigned Assistant
     shUserForm.getRange("ContactId").clear(); //Contact ID
     shUserForm.getRange("B1FName").clear(); //firstname
     shUserForm.getRange("B1MName").clear(); //middle name
     shUserForm.getRange("B1LName").clear(); //last name
     shUserForm.getRange("B1BirthDate").clear(); //Birthday
     shUserForm.getRange("MaritalStatus").clear(); // Status
     shUserForm.getRange("B1Spouse").clear(); //Spouse
     shUserForm.getRange("B1MobileNumber").clear(); //B1MobileNumber
     shUserForm.getRange("B1HomePhone").clear(); //B1HomePhone
     shUserForm.getRange("B1Email").clear(); //email address
     shUserForm.getRange("B1UnitNumber").clear();//B1UnitNumber
     shUserForm.getRange("B1StreetNumber").clear();//B1StreetNumber
     shUserForm.getRange("B1StreetName").clear(); //B1StreetName
     shUserForm.getRange("B1StreetDirection").clear(); //firstname
     shUserForm.getRange("B1StreetType").clear();//Street Type
     shUserForm.getRange("B1City").clear(); //City
     shUserForm.getRange("B1Province").clear();//B1Province
     shUserForm.getRange("B1Country").clear();//firstname
     shUserForm.getRange("B1Postal").clear();//firstname
     shUserForm.getRange("CallAnswered").clear(); //if call is answered
     shUserForm.getRange("CallDate").clear(); //Date call to the client
     shUserForm.getRange("Validated").clear(); //Validated
     shUserForm.getRange("Consider").clear();//refinancing, buying, selling, or investing in international real estate in the US    
     shUserForm.getRange("notes").clear();//notes    

  }
}




cwl...@gmail.com

unread,
Sep 9, 2023, 6:01:28 AM9/9/23
to Google Apps Script Community
I think the error is coming from here:
shUserForm.getActiveRange("ContactId").getValue()+ '"');
Change this to :   shUserForm.getRange("ContactId").getValue()+ '"'); //and see if that helps

Jay Anne Otadora

unread,
Sep 10, 2023, 8:30:30 PM9/10/23
to Google Apps Script Community
As per checking this Contact ID no longer exists on the form and I overlooked this label. 
so I removed all the instruction for this specific label there it work!
You are such a great help, especially to a beginner 

Reply all
Reply to author
Forward
0 new messages