Google Apps 脚本条件 If/Else If 语句 [英] Google Apps Script Conditional If/Else If Statement

查看:25
本文介绍了Google Apps 脚本条件 If/Else If 语句的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

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

推荐答案

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

You should use == for comparing , not =

if (urgency == "Critical")

等等..

这篇关于Google Apps 脚本条件 If/Else If 语句的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆