Hey there, I am trying to get my on scan property to add to the quantity of the scanned item if it's scanned multiple times, rather than adding more entries. I have no idea what I am doing wrong as the below seems to make sense but every scanned item goes in as a new record entry, help! - what am I missing here? - Here is what I've got:
Set(
CurrentRecord,
LookUp(
'Copy of catalogue - 07-20-2021',
Value(BarcodeScanner1.Value) = GTIN,
ThisRecord
)
);
Set(
Barcode1,
Value(BarcodeScanner1.Value)
);
Set(
Varscn,
true
);
Collect(
colLimit,
{
Limit: CurrentRecord.'Dried Flower Cannabis Equivalency',
Title: CurrentRecord.Title
}
);
If(
Sum(
colLimit.Limit,
Limit
) > 30,
Set(
varWarning,
true
)
);
If(
Sum(
colLimit.Limit,
Limit
) <= 30,
If(
CurrentRecord.GTIN = Barcode1,
Patch(
colShoppingCart1,
LookUp(
colShoppingCart1,
Barcode1 = Barcode,
ThisRecord
),
{
Qty: Qty + 1,
Title: CurrentRecord.Title
}
),
Collect(
colShoppingCart1,
{
Title: CurrentRecord.Title,
MemberID: VarMember,
ProductPrice: CurrentRecord.'Unit Price',
SKU: CurrentRecord.'OCS Variant Number',
Size: CurrentRecord.Size,
Barcode: CurrentRecord.GTIN,
Qty: Value(1),
Equiv: CurrentRecord.'Dried Flower Cannabis Equivalency',
Image: CurrentRecord.'Image URL',
Subtotal: CurrentRecord.'Unit Price',
Remain: CurrentRecord.'Eaches Per Master Case' - 1,
RemStock: CurrentRecord.'Eaches Per Master Case' - 1
}
)
);
Patch(
'Copy of catalogue - 07-20-2021',
CurrentRecord,
{'Eaches Per Master Case': CurrentRecord.'Eaches Per Master Case' - 1}
),
Remove(
colLimit,
Last(colLimit)
)
)
Hi @Apolmans1
Here is the updated code.
Set(
Barcode1,
Value(BarcodeScanner1.Value)
);
Set(
CurrentRecord,
LookUp(
'Copy of catalogue - 07-20-2021',
Barcode1 = GTIN,
ThisRecord
)
);
Collect(
colLimit,
{
Limit: CurrentRecord.'Dried Flower Cannabis Equivalency',
Title: CurrentRecord.Title
}
);
If(
Sum(
colLimit.Limit,
Limit
) > 30,
Set(
varWarning,
true
);
Remove(
colLimit,
Last(colLimit)
),
If(
CurrentRecord.GTIN = Barcode1,
Patch(
colShoppingCart1,
LookUp(
colShoppingCart1,
Barcode1 = Barcode,
ThisRecord
),
{
Qty: Qty + 1,
Title: CurrentRecord.Title
}
);
Patch(
'Copy of catalogue - 07-20-2021',
CurrentRecord,
{'Eaches Per Master Case': CurrentRecord.'Eaches Per Master Case' - 1}
),
Collect(
colShoppingCart1,
{
Title: CurrentRecord.Title,
MemberID: VarMember,
ProductPrice: CurrentRecord.'Unit Price',
SKU: CurrentRecord.'OCS Variant Number',
Size: CurrentRecord.Size,
Barcode: CurrentRecord.GTIN,
Qty: 1,
Equiv: CurrentRecord.'Dried Flower Cannabis Equivalency',
Image: CurrentRecord.'Image URL',
Subtotal: CurrentRecord.'Unit Price',
Remain: CurrentRecord.'Eaches Per Master Case' - 1,
RemStock: CurrentRecord.'Eaches Per Master Case' - 1
}
)
)
)
For testing
Set(
Barcode1,
Value(TextInput1.Text)
);
Ok now I am just lost, last night this same code at least was adding the scanned items to my collection as new items every time, as of this morning when I tried it wont scan at all.... I probably messed with something before bed but I don't know what the heck I did to break it... The one thing I noticed about the above code was that I was comparing the wrong fields on the second if statement, changed that to compare my scanned value to a look up of the collection and since then it won't scan at all, even if I revert back... WTF!
Set(
CurrentRecord,
LookUp(
'Copy of catalogue - 07-20-2021',
Value(BarcodeScanner1.Value) = GTIN,
ThisRecord
)
);
Set(
Barcode1,
Value(BarcodeScanner1.Value)
);
Set(
Varscn,
true
);
Collect(
colLimit,
{
Limit: CurrentRecord.'Dried Flower Cannabis Equivalency',
Title: CurrentRecord.Title
}
);
If(
Sum(
colLimit.Limit,
Limit
) > 30,
Set(
varWarning,
true
)
);
If(
Sum(
colLimit.Limit,
Limit
) <= 30,
If(
CurrentRecord.GTIN = Barcode1,
Patch(
colShoppingCart1,
LookUp(
colShoppingCart1,
Barcode1 = Barcode,
ThisRecord
),
{
Qty: Qty + 1,
Title: CurrentRecord.Title
}
),
Collect(
colShoppingCart1,
{
Title: CurrentRecord.Title,
MemberID: VarMember,
ProductPrice: CurrentRecord.'Unit Price',
SKU: CurrentRecord.'OCS Variant Number',
Size: CurrentRecord.Size,
Barcode: CurrentRecord.GTIN,
Qty: Value(1),
Equiv: CurrentRecord.'Dried Flower Cannabis Equivalency',
Image: CurrentRecord.'Image URL',
Subtotal: CurrentRecord.'Unit Price',
Remain: CurrentRecord.'Eaches Per Master Case' - 1,
RemStock: CurrentRecord.'Eaches Per Master Case' - 1
}
)
);
Patch(
'Copy of catalogue - 07-20-2021',
CurrentRecord,
{'Eaches Per Master Case': CurrentRecord.'Eaches Per Master Case' - 1}
),
Remove(
colLimit,
Last(colLimit)
)
)
Here is the code formatted correctly, please let me know what I'm doing wrong, code works to add new items to the cart/collection but will add a second entry rather than patching the exiting one on the second scan.
Hi @Apolmans1
We can use Patch(data source, Collection1) when a collection has the right keys. Can you format your code and share it with us. That will be easy to read and understand.