mercredi 23 mars 2022

Checkbox value not showing up right in Google Apps Script

I am having an issue were the values I have setup in the Data Validation for my check boxes in cells C3 and D3 are not showing up correct. I set the values of "Yes" for checked and "No" for unchecked. A3 has Customer's Name and B3 is FT or PT.

I added the alert to display what all the values are and if the If/Else statement was working but regardless of whether the checkbox is checked or not it returns the values of Yes.

function ContactType() {
var spreadsheet = SpreadsheetApp.getActiveSpreadsheet();
var DBSheet = spreadsheet.getSheets()[0];

var ConType  = SpreadsheetApp.setActiveSheet(DBSheet).getRange('A3').getValue();
var CatType  = SpreadsheetApp.setActiveSheet(DBSheet).getRange('B3').getValue();
var spd = "None"
var spdcb = "None"
var dec = "None"
var deccb = "True"
var deccb = SpreadsheetApp.getActiveSheet().getRange('D3').getValue();
var spdcb = SpreadsheetApp.getActiveSheet().getRange('C3').getValue();

if (spdcb = "Yes")  
  spd = "Not Suspended";
  else if (spdcb = 'No')
    spd = "Suspended"
  
if (deccb = 'Yes')  
  dec = "Returned";
  else if (deccb = 'No')
    dec = "Not Returned" 

SpreadsheetApp.getUi().alert('The Contact type is '+ConType +'\r\n The Category Type is '+CatType +'\r\n The Suspension checkbox is ' +spdcb + '\r\n The Suspension status is '+spd +'\r\n The Reinstatement Declaration is ' +deccb + '\r\n The Reinstatement Declaration is '+dec);

}

I have tried changing the data validation to different values but got the same result.

I am hoping that the checkbox value will be correctly recognized and the If/Else to return the correct values for the other variables.




Aucun commentaire:

Enregistrer un commentaire