Не удается вызвать перегруженный конструктор setValue с параметрами ((класс)) - карта Gmail добавлена - PullRequest
0 голосов
/ 30 января 2020

Я работаю с надстройкой Gmail, которая собирает данные электронной почты и сохраняет их в нашей базе данных. Тем не менее, я всегда получаю сообщение об ошибке

"Невозможно вызвать перегруженный конструктор setValue с параметрами ((класс)), поскольку существует более одной совпадающей сигнатуры конструктора: interface CardService.TextInput setValue (number) interface CardService.TextInput setValue (String) [строка: 87, функция: createFormSection, файл: карты] "

Я перепробовал все, что знал, но не повезло.

Это мой код:

function createFormSection(section, opt_prefills) {

      var dateAssigned = CardService.newTextInput()
      .setFieldName("dateAssigned")
      .setTitle("Date Assigned")
      .setValue(opt_prefills[0]);

      var AssignerName = CardService.newTextInput()
      .setFieldName("AssignerName")
      .setTitle("Assigner Name")
      .setValue(opt_prefills[1]);

       var AssignerEmail = CardService.newTextInput()
      .setFieldName("AssignerEmail")
      .setTitle("Assigner Email")
      .setValue(opt_prefills[2]);

       var ClientName = CardService.newTextInput()
      .setFieldName("ClientName")
      .setTitle("Client Name")
       .setValue(opt_prefills[3]);

       var CandidateOrCaseName = CardService.newTextInput()
      .setFieldName("CandidateOrCaseName")
      .setTitle("Candidate Or Case Name")
       .setValue(opt_prefills[4]);

       var CandidateEmailOnly = CardService.newTextInput()
      .setFieldName("CandidateEmailOnly")
      .setTitle("Candidate Email Only")
       .setValue(opt_prefills[5]);

       var Assignment = CardService.newTextInput()
      .setFieldName("Assignment")
      .setTitle("Assignment")
       .setValue(opt_prefills[6]);

       var Attachment = CardService.newTextInput()
      .setFieldName("Attachment")
      .setTitle("Attachment")
      .setValue(opt_prefills[7]);


   var servicedropdown = CardService.newSelectionInput()
    .setType(CardService.SelectionInputType.DROPDOWN)
    .setTitle("Service")
    .setFieldName("servicedropdown")
    .addItem("Pre-Employment Background", "Pre-Employment Background", true)
    .addItem("Peace Officer Lateral", "Peace Officer Lateral", false)


    var positiondropdown = CardService.newSelectionInput()
    .setType(CardService.SelectionInputType.DROPDOWN)
    .setTitle("Position or Type")
    .setFieldName("positiondropdown")
    .addItem("Peace Officer Lateral", "Peace Officer Lateral", true)
    .addItem("Private Investigation", "Private Investigation", false)

  section.addWidget(dateAssigned);
  section.addWidget(AssignerName);
  section.addWidget(AssignerEmail);
  section.addWidget(ClientName);
  section.addWidget(servicedropdown);
  section.addWidget(positiondropdown);
  section.addWidget(CandidateOrCaseName); 
  section.addWidget(CandidateEmailOnly);
  section.addWidget(Assignment);
  section.addWidget(Attachment);    

  return section;
}

function submitForm(e) {

 var res = e['formInput'];

  var receivedOn = res['dateAssigned'];
  var status = 'Active';
  var subjectName = res['CandidateOrCaseName'];
  var subjectEmail = res['CandidateEmailOnly'];
  var agencyName = res['ClientName'];
  var serviceName = res['servicedropdown'];
  var typeName = res['positiondropdown'];
  var assignerName = res['AssignerName'];
  var assignerEmail = res['AssignerEmail'];
  var assignment = res['Assignment'];
  var attachment = res['Attachment'];

  var data = ['dateAssigned','CandidateOrCaseName','CandidateEmailOnly','ClientName', 'AssignerName','AssignerEmail','Assignment','Attachment']

var userEmail = Session.getActiveUser().getEmail();
var username = userEmail.substring(0, userEmail.indexOf("@"));

  try {
    data.forEach(function(fieldName) {
      if (!res[fieldName]) {
        throw 'Please complete required fields';
      }
    });
     var date = new Date();
  var currentDate = ((date.getMonth() > 8) ? (date.getMonth() + 1) : ('0' + (date.getMonth() + 1))) + '/' + ((date.getDate() > 9) ? date.getDate() : ('0' + date.getDate())) + '/' + date.getFullYear();


  var driveId = "SampleDriveID";  //createDrive(subjectName,typeName,serviceName,agencyName);
  var code = "SampleCode";  //createCode(agencyName, subjectName, typeName, date);

  var connectionName = 'xxxxx';
  var user = 'xxxxx';
  var userPwd = 'xxxxx';
  var db = 'xxxxx';
  var dbUrl = 'jdbc:google:mysql://' + connectionName + '/' + db;
  var conn = Jdbc.getCloudSqlConnection(dbUrl, user, userPwd);

  //var conn = getConnection();
  var stmt = conn.prepareStatement("INSERT INTO Subject "+
                                   " (SubjectName, AddedBy, AddedOn, UpdatedBy, UpdatedOn, AssignerName, AssignerEmail, AssignedOn, SubjectDetails, SubjectLink, SubjectStatus, SubjectDriveId, SubjectCode, SubjectService, SubjectType, SubjectAgency, SubjectEmail) VALUES " + 
                                   " (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?);");

  stmt.setString(1, subjectName);
  stmt.setString(2, userEmail);
  stmt.setTimestamp(3, Jdbc.parseTimestamp(Utilities.formatDate(new Date(currentDate), Session.getScriptTimeZone(), 'yyyy-MM-dd HH:mm:ss')));
  stmt.setString(4, userEmail);
  stmt.setTimestamp(5, Jdbc.parseTimestamp(Utilities.formatDate(new Date(currentDate), Session.getScriptTimeZone(), 'yyyy-MM-dd HH:mm:ss')));
  stmt.setString(6, assignerName);
  stmt.setString(7, assignerEmail);
  stmt.setTimestamp(8, Jdbc.parseTimestamp(Utilities.formatDate(new Date(receivedOn), Session.getScriptTimeZone(), 'yyyy-MM-dd HH:mm:ss')));
  stmt.setString(9, assignment);
  stmt.setString(10, attachment);
  stmt.setString(11, status);
  stmt.setString(12, driveId);
  stmt.setString(13, code);
  stmt.setString(14, serviceName);
  stmt.setString(15, typeName);
  stmt.setString(16, agencyName);
  stmt.setString(17, subjectEmail);

  stmt.executeUpdate();

    stmt.close();
    conn.close();
var message = "Record created for " + subjectName + ' by ' + userEmail;
    return getEmailDetails(null, message).build();
  }
  catch (err) {
return getEmailDetails(objToArray(res, data), 'Error: ' + err.message).build();
    }
  }

function objToArray(obj, keys) {
  return keys.map(function(key) {
    return obj[key];
  });
}

function clearForm(e) {
  return getEmailDetails(null, e['parameters']['Status']).build();
}

У меня вопрос, как правильно получить названия полей и значений моего аддона gmail? Надеюсь, кто-нибудь сможет мне помочь. Спасибо!

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...