文本字段如何判断为空
金蝶云社区-ChengJeremy
ChengJeremy
2人赞赏了该文章 3296次浏览 未经作者许可,禁止转载编辑于2017年03月05日 11:30:23

我在单据上添加了一个文本字段:F_PAEZ_SEOrderNo,当这个字段为空时,对其进行赋值,在python脚本中设置条件:if this.Model.GetValue("F_PAEZ_SEOrderNo")==null or this.Model.GetValue("F_PAEZ_SEOrderNo")="":
进行赋值,现在脚本已经添加好,但在单据保存时,总报如下 错误:

请问如何处理。
删除这个字段,重新添加一个文本,字段名称为:F_PAEZ_SEOrderNumber,不报错了,但赋值还是赋不上。
代码如下:
#Set-SaleOrderBillNo-Value 设置表体1行文本字段值
#by Chengjx 2017-2-27
def BarItemClick(e):
if (this.Model.GetValue("FDOCUMENTSTATUS")=="A" or this.Model.GetValue("FDOCUMENTSTATUS")=="D" or this.Model.GetValue("FDOCUMENTSTATUS")=="Z") and (this.Model.GetValue("F_PAEZ_SEOrderNumber")==null or this.Model.GetValue("F_PAEZ_SEOrderNumber")==""):
if this.Model.GetEntryRowCount("FEntity")>=1:
this.Model.SetValue("F_PAEZ_SEOrderNumber",this.Model.GetValue("FSrcBillNo",0))
else:
this.Model.SetValue("F_PAEZ_SEOrderNumber","")

换另外一个代码也不行:
#Set-SaleOrderBillNo-Value 设置表体1行文本字段值
#by Chengjx 2017-2-27
def BarItemClick(e):
if (this.Model.GetValue("FDOCUMENTSTATUS")=="A" or this.Model.GetValue("FDOCUMENTSTATUS")=="D" or this.Model.GetValue("FDOCUMENTSTATUS")=="Z") and len(this.Model.GetValue("F_PAEZ_SEOrderNumber"))=0:
if this.Model.GetEntryRowCount("FEntity")>=1:
this.Model.SetValue("F_PAEZ_SEOrderNumber",this.Model.GetValue("FSrcBillNo",0))
else:
this.Model.SetValue("F_PAEZ_SEOrderNumber","")