Hi @Anonymous,
Could you please share a bit more about your scenario?
How do you randomly pick 1 factory within your app?
Could you please share more details about your data source?
I assume that you use a data source to store all works in all factories, and there are some columns within it, e.g. WorkerName, Email (store Worker's email), FactoryName, ... etc.
I think your thought is proper, I think the Shuffle() function could achieve your needs. I have made a test on my side, please take a try with the following workaround:
On your side, add a "Random Workers" button within your app, set the OnSelect property to following:
ClearCollect(
RandomWorkersCollection,
FirstN(
Shuffle(Filter('datasource', FactoryName = OutputFactory)),
6
)
)
Note: The Filter('datasource', FactoryName = OutputFactory) formula would return all workers in the random output factory generated in your Step 1.
The Shuffle function would randomly reorder all workers in the random output factory generated in your Step 1.
Then for your third step, I think the Office365.SendEmail() function could achieve your needs. On your side, please take a try with the following formula:
ForAll(
RandomWorkersCollection,
Office365.SendEmail(Email,"Spot Check Notification", "You have been chosen for spot checks") /* <- Email represents the Email column in your data source */
)
At last, you should type the following formula within the OnSelect property of the "Random Workers" button:
ClearCollect(
RandomWorkersCollection,
FirstN(
Shuffle(Filter('datasource', FactoryName = OutputFactory)),
6
)
);
ForAll(
RandomWorkersCollection,
Office365.SendEmail(Email,"Spot Check Notification", "You have been chosen for spot checks") /* <- Email represents the Email column in your data source */
)
More details about the Filter function and Shuffle function in PowerApps, please check the following article:
Filter function
Shuffle function
Best regards,
Kris