ForAll函数创建
范围
它具有您试图引用的ThisRecord对象。但是LookUp函数也会创建自己的作用域,ThisRecord总是指最近的作用域。
如果要引用在ForAll函数中创建的作用域,可以使用As关键字为其命名,并使用该名称进行引用:
ForAll(
Self.Barcodes As TheBarcode,
If(
!IsBlank(
LookUp(barcode_inventory,Barcode = Value(TheBarcode.Value), Barcode)
),
Collect(
signed_out,
{
Barcode: Value(TheBarcode.Value),
Product: Text(LookUp(barcode_inventory,Barcode = Value(TheBarcode.Barcode)).ProductNameSize)
}
),
Notify("Could not find record.", NotificationType.Error)
)
)
顺便说一句,您可以通过使用with函数缓存LookUp值来提高效率,这样就不必执行两次:
ForAll(
Self.Barcodes As TheBarcode,
With(
{ productFromInventory: LookUp(barcode_inventory,Barcode = Value(TheBarcode.Value) },
If(
!IsBlank(productFromInventory.Barcode),
Collect(
signed_out,
{
Barcode: Value(TheBarcode.Value),
Product: Text(productFromInventory.ProductNameSize)
}
),
Notify("Could not find record.", NotificationType.Error)
)
)