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
}
}