I made a barcode scanner and if i scan it, it writes a couple of things to a sharepoint list. I have one columt in sharepoint called locatie. This is a lookup field with some simple shelves. I want to say that if a barcode is scanned it picks a rondom available field of that dropdown. The fields are unique, since i cant store more than 1 product on a shelf. The problem is that i do not find how i can do this.
Hello @reinaerd
Achieving what You are looking for is complicated. I hope all that I put down here will make sense.
First, there are a few flows that we need to sort in Your logic to make sure You are not running into some unexpected error.
1. There is one available location per product, so the relationship One-To-One means You need to find a way to remove locations currently used by live products that were related to each location.
2. You must prevent any products from being added when Your Storage / Warehouse runs out of available Locations.
3. Also, You need to notify the user that's what happens so the user can investigate and make space if possible.
Here is my proposal for what You could implement:
To your List of Locations, add column Text called "Status" and make a mass edit to change all records to "Empty"
Next, apply this code to the Button that is currently patching your Scanner input:
Important make sure the names of Columns and Lists are maching and I did not make any mistakes I try place names to match Your Screens, but I could missspeal something.
If(
CountRows(
Filter(
Shelving,
Status = "Empty"
).Titel
) <= 0,
Notify("No Available Locations Make Space"),
Set(
varLoc,
Patch(
'Barcode Scans',
Defaults('Barcode Scans'),
{
Titel: BarcodeScanner2.Value,
'Barcode Type': BarcodeScanner2.Type,
'Scanned Person':User().FullName,
'Scanned time': Now(),
Locatie: First(
Shuffle(
Filter(
Shelving,
Status = "Empty"
)
)
).Titel
}
)
)
);
Patch(
Shelving,
LookUp(
Shelving,
Titel = varLoc.Locatie
),
{Status: "In Use"}
)
Now the only process You will need to implement is when You will change the status of the Location back to empty if this will be a manual process when someone doing an audit and changing the status, or it will be automated example when the product will run out I leave this to You.
hope this help
Hello @reinaerd
Achieving what You are looking for is complicated. I hope all that I put down here will make sense.
First, there are a few flows that we need to sort in Your logic to make sure You are not running into some unexpected error.
1. There is one available location per product, so the relationship One-To-One means You need to find a way to remove locations currently used by live products that were related to each location.
2. You must prevent any products from being added when Your Storage / Warehouse runs out of available Locations.
3. Also, You need to notify the user that's what happens so the user can investigate and make space if possible.
Here is my proposal for what You could implement:
To your List of Locations, add column Text called "Status" and make a mass edit to change all records to "Empty"
Next, apply this code to the Button that is currently patching your Scanner input:
Important make sure the names of Columns and Lists are maching and I did not make any mistakes I try place names to match Your Screens, but I could missspeal something.
If(
CountRows(
Filter(
Shelving,
Status = "Empty"
).Titel
) <= 0,
Notify("No Available Locations Make Space"),
Set(
varLoc,
Patch(
'Barcode Scans',
Defaults('Barcode Scans'),
{
Titel: BarcodeScanner2.Value,
'Barcode Type': BarcodeScanner2.Type,
'Scanned Person':User().FullName,
'Scanned time': Now(),
Locatie: First(
Shuffle(
Filter(
Shelving,
Status = "Empty"
)
)
).Titel
}
)
)
);
Patch(
Shelving,
LookUp(
Shelving,
Titel = varLoc.Locatie
),
{Status: "In Use"}
)
Now the only process You will need to implement is when You will change the status of the Location back to empty if this will be a manual process when someone doing an audit and changing the status, or it will be automated example when the product will run out I leave this to You.
hope this help