Google Apps脚本条件If / Else If Statement

时间:2013-12-05 15:31:37

标签: google-apps-script google-sheets

我在下面有这个脚本,但它不断返回不正确的信息。例如,即使“紧急度”可能等于“中等”,它也会返回“关键”结果。

var initialcontact;
var row = sheet.getActiveRange().getRowIndex();
var urgency = sheet.getRange(row, getColIndexByName("Urgency")).getValue();
if (urgency = "Critical") {initialcontact = "1 hour";}
else if (urgency = "High") {initialcontact = "4 hours";}
else if (urgency = "Medium") {initialcontact = "1 day";}
else if (urgency = "Low") {initialcontact = "3 days";}

1 个答案:

答案 0 :(得分:2)

您应该使用==进行比较,而不是=

if (urgency == "Critical")

依旧......