cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Advocate I
Advocate I

App Feasibility Query

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

1 ACCEPTED SOLUTION

Accepted Solutions
Community Support
Community Support

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:10.JPG

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

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

2 REPLIES 2
Community Support
Community Support

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:10.JPG

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

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

Cheers Kris, much appreciated, that definitely helped! 🙂

Helpful resources

Announcements
secondImage

Experience what’s next for Power Apps

Join us for an in-depth look at the new Power Apps features and capabilities at the free Microsoft Business Applications Launch Event.

Power Apps Community Call

Power Apps Community Call: February

Did you miss the call? Check out the Power Apps Community Call here.

New Power Super Users

Congratulations!

We are excited to announce the Power Apps Super Users!

New Badges

New Solution Badges!

Check out our new profile badges recognizing authored solutions!

Top Solution Authors
Top Kudoed Authors
Users online (9,225)