Google Apps Script Conditional If/Else If Statemen

2019-01-29 13:01发布

I've got this script below but it keeps returning the incorrect information. For instance, even though the "urgency" may equal "medium", it returns the "critical" result.

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条回答
Animai°情兽
2楼-- · 2019-01-29 13:37

You should use == for comparing , not =

if (urgency == "Critical")

and so on..

查看更多
登录 后发表回答