cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
gavinleung
Level 8

Multiple Sharepoint List item by PowerApps or Flow

Hi all, 

 

I'm developing a simple solution to the users, allowing them to define tasks by day by month, replicate repetitive tasks to another month, update the time spent. Now, I'm using PowerApps to define tasks, and let users to update the time spent on a specific task. The records are stored in Sharepoint List with the following fields:

1. Title (task title) --- Text

2. Assigned To (the leader assigns a task to a member) --- Person / Group

3. Expected Time Spent --- Date/Time

4. Actual TIme Spent --- Date/Time

5. Completed ? {Yes | No} --- Yes/No

6. Recurrence ? {Daily | Weekly | Monthly} --- Text

 

I can't find any reference by using PowerApps to create multiple List records (if recurrence is checked). So I planned to use Flow to trigger an action when Recurrence contains value. 

 

Any advice / any experience / any idea to share ? 

 

Much thanks!

Gavin

 

 

2 ACCEPTED SOLUTIONS

Accepted Solutions
gavinleung
Level 8

Re: Multiple Sharepoint List item by PowerApps or Flow

Thanks @shailendra74 ! I got it done, and my final code:

 

ClearCollect(collRecurrence,[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30]);
UpdateContext({FREQUENCY: Switch(Dropdown2.Selected.Value , "Daily", 1, "Weekly", 7, "Monthly", 30)});
ForAll(
Filter(
collRecurrence,
Value < Value(txtOccurences.Text)
),
Patch(
'Standard Work Plan', Defaults('Standard Work Plan'),
{
'Title': DataCardValue7.Text,
'Assigned To': DataCardValue8.Selected,
'Date': DateAdd(DataCardValue9.SelectedDate, FREQUENCY * Value),
'Std Minutes':Value(DataCardValue11.Text)
}
)
);
Navigate(BrowseScreen1)

View solution in original post

shailendra74
Level 10

Re: Multiple Sharepoint List item by PowerApps or Flow

Hi @gavinleung 

 

Cheers!!!!

 

If the previous response helps, then please consider Accept it as the solution to help the other members 

 

Thanks.

View solution in original post

13 REPLIES 13
shailendra74
Level 10

Re: Multiple Sharepoint List item by PowerApps or Flow

Hi @gavinleung 

 

Just a thought when recurrence is selected.

 

ClearCollect(collRecurrence,[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30]);
Clear(collData);
ForAll( Filter(collRecurrence, Value <= Value(txtOccurrences.Text)), Collect(collData, { Row: Value}))
  1. Consider you set the number of recurrences is restricted to 30.
  2. Create a collection collRecurrence with an array of 30 numbers
  3. Calculate the Occurrences - difference between the dates (divided) by interval
  4. Use ForAll and filter on Occurrence from the  collRecurrences (array collection)
  5. Use collect to add multiple recurrences

Based on above code and the points, if you set txtOccurrence.text to 10, you can add 10 records in collData.

 

I've set any validate to check occurrence > 30.

 

This is just a basic but hope this might help you.

 

Thanks.

gavinleung
Level 8

Re: Multiple Sharepoint List item by PowerApps or Flow

Thanks @shailendra74 , I think I got to elaborate a bit more. 

 

On my Task creation screen, I have a check box on the screen, when clicked, a dropdown list allows the user to pick "Daily", "Weekly", and "Monthly". Then this task is going to be repeated. 

 

A task (without recurrence) will contain the info such as task description, assigned to, assignment date, expected time spent. While a task (with recurrence) will contain the info similar as above, but a second entry should be created with the "assignment date" + 7 days (if weekly). 

 

I have no idea whether this could be achieved by PowerApps... 

shailendra74
Level 10

Re: Multiple Sharepoint List item by PowerApps or Flow

Hi @gavinleung 

 

The code which I provided is as per your requirement. Here is the code with a tweak (marked in red):

 

 

ClearCollect(collRecurrence,[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30]);
Clear(collData); 
UpdateContext({FREQUENCY: Switch(rdoFrequency.Selected.Value , "Daily", 1, "Weekly", 7, "Monthly", 30)}); ForAll( Filter( collRecurrence, Value < Value(txtOccurrences.Text) ), Collect( collData, { Row: (Value+1), taskdescription: "task 1", assignedto: "resource 1", assignmentdate: DateAdd( dpStartDate.SelectedDate, (FREQUENCY * Value) ), expectedtimespent: "10 mins" } ) )

here is the output

 

 

Screenshot 2019-08-06 at 2.22.09 PM.png

 

 

Place a datatable and set the datasource to collData and select the fields. Other controls:

dpStartDate - Date control name

txtOccurrences - occurrence

rdoFrequency - radio control with ["Daily", "Weekly", "Monthly"] in items property

btnCalculate - Put above code in onSelect

 

please note this collection is to collect data when recurrence is checked.  Based on the outcome,  you can update your database accordingly.

 

gavinleung
Level 8

Re: Multiple Sharepoint List item by PowerApps or Flow

Thanks @shailendra74 . Need some test, let you know if this works to me. 

gavinleung
Level 8

Re: Multiple Sharepoint List item by PowerApps or Flow

Hi @shailendra74 , 

 

I'm using SubmitForm() to submit the data card values to my Sharepoint list. In the sample you created, can the array be submitted ? 

 

Sorry...i'm quite new to PowerApps. 

 

Thanks,

Gavin

shailendra74
Level 10

Re: Multiple Sharepoint List item by PowerApps or Flow

Hi @gavinleung 

 

You need to tweak your arary to table or collection and save the same.

 

When you split array the return value would be a table. You can use ForAll and Patch to SP.

 

ForAll(CollectionName, Patch(SharePoint_ListName, Defaults(SharePoint_ListName), 
{ ColumnName1: value1, ColumnName2: value2, etc})

 

Thanks. 

gavinleung
Level 8

Re: Multiple Sharepoint List item by PowerApps or Flow

Tried ... but no luck. Still doing troubleshooting. 

 

None records are being write into the List . 

shailendra74
Level 10

Re: Multiple Sharepoint List item by PowerApps or Flow

Hi @gavinleung 

 

Can you share your code.

 

Thanks.

gavinleung
Level 8

Re: Multiple Sharepoint List item by PowerApps or Flow

Thanks @shailendra74 

 

Please see my Sharepoint List and the App Screen.

 

This is the code I used:

ClearCollect(collRecurrence,[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30]);
Clear(collData);
UpdateContext({FREQUENCY: Switch(rdoFrequency.Selected.Value , "Daily", 1, "Weekly", 7, "Monthly", 30)});
ForAll(collRecurrence, Patch('Standard Work Plan', Defaults('Standard Work Plan'),
{ 'Title': DataCardValue8, 'Assigned To': DataCardValue9, 'Assignment Date': DateAdd(DataCardValue10.SelectedDate, FREQUENCY) ,'Standard Minutes':DataCardValue11})

 

There is no erro ... but there is no record being created on SP. 

Helpful resources

Announcements
thirdimage

Power Apps Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

sixthImage

Power Platform World Tour

Find out where you can attend!

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

SecondImage

Difinity Conference

The largest Power BI, Power Platform, and Data conference in New Zealand

Top Solution Authors
Top Kudoed Authors (Last 30 Days)
Users online (5,733)