Hi all, I`m trying to create a company app for a specific department but have hit a brick wall. Scouring the web for advice/help/tutorials hasnt thrown up any solutions. If I list the main part of the process I`m trying to automate in the app could someone tell me if its possible?
I`ve got 12 factories and each factory has a set number of workers.
1. I want to randomly pick 1 factory
2. Then randomly pick 6 workers from that factory.
3. Once those workers have been chosen at random I want to mail them.
I`ve found a solution to the first part of the process, my next hurdle is then using the output factory to pick 6 random workers for checks. The RAND function really only applies to numbers, and even then it really just randomises the decimal number. There is a shuffle function but not sure if thats a feasible option and if so, how I can make it shuffle the list of workers and only show the first 6. And if we reach that point how we can then link those workers to mail addresses so mails can be sent to all 6 to notify them they`ve been chosen for spot checks.
If anyone can let me know if this is even possible I`d be incredibly grateful.
Regards
ALan Dobson
Solved! Go to Solution.
Hi @RedAl,
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:
Best regards,
Kris
Hi @RedAl,
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:
Best regards,
Kris
Cheers Kris, much appreciated, that definitely helped! 🙂
User | Count |
---|---|
232 | |
109 | |
94 | |
59 | |
29 |
User | Count |
---|---|
293 | |
126 | |
106 | |
62 | |
57 |