cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
dm_elementwa
Level: Powered On

Update or create new item in Sharepoint from form

SCENARIO:

Capturing staff capacities for the week.

Staff member opens the microsoft form and just enters a number between 0 and 100 of how much time they think they'll have available for the following week.

This then updates a sharepoint list and displays the data as a Quick Chart on our sharepoint page.

Something happens through the week and a staff member wants to edit their capacity.

They resubmit a form and it overwrites the previous entry.

-----------------------------------------------------------------------

I've come really close to solving this one thanks to this: https://powerusers.microsoft.com/t5/Building-Flows/Update-existing-or-create-a-new-SharePoint-item-v...

 

BUT!

 

In my case, I have staff submitting a form and in the past I have used the "Get user profile" and from that "Given Name" and had this as the Title column or ID column in my Sharepoint list, and then the data from their response in the next column.


I need the ability to detect previous items already in the sharepoint list and update according to name, and if it doesn't detect a name already in the list, then create a new item.

I've tried the above but get stuck at the user ID bit... any suggestions?

Screen Shot 2019-10-02 at 11.44.31 am.pngScreen Shot 2019-10-02 at 11.45.27 am.pngScreen Shot 2019-10-02 at 11.44.13 am.png

10 REPLIES 10
Dual Super User
Dual Super User

Re: Update or create new item in Sharepoint from form

If you are using the Given Name as the value for title in SharePoint, then you should be able to do a Get Items in the Flow with an OData filter for Title eq 'Given Name'.  Then check to see if that returns any records.  If it does then you can use the First ID from that get items as the item you want to update.  If no records were returned then add a new record. Something like this

screenshot.png



-------------------------------------------------------------------------
If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.
Highlighted
dm_elementwa
Level: Powered On

Re: Update or create new item in Sharepoint from form

Thanks @Pstork1 , 

Still seem to be having an issue though... I've run the test and it gets stuck on the spinny wheel of death.

Here's a copy of my current flow.Screen Shot 2019-10-03 at 8.42.18 am.png

Dual Super User
Dual Super User

Re: Update or create new item in Sharepoint from form

Can you send the screenshot of the Flow in several sections?  The resolution on the screenshot you embedded is just to  low to be readable.  Also, when you look at the failed Flow runs where is it timing out?  What action.



-------------------------------------------------------------------------
If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.
dm_elementwa
Level: Powered On

Re: Update or create new item in Sharepoint from form

Oh, so sorry. Here are individual screen captures.

 

And I don't even get the chance to see where the failures are when I run the test. I hit test, submit a form and it just stays on a blank screen. No run reports, no errors. Nothing. Just blank with a spinning circle.

 

Screen Shot 2019-10-03 at 9.39.37 am.pngScreenshot 1Screen Shot 2019-10-03 at 9.39.54 am.pngScreenshot 2Screen Shot 2019-10-03 at 9.40.05 am.pngScreenshot 3Screen Shot 2019-10-03 at 9.40.21 am.pngScreenshot 4Screen Shot 2019-10-03 at 9.40.28 am.pngScreenshot 5

Community Support Team
Community Support Team

Re: Update or create new item in Sharepoint from form

Hi @dm_elementwa,

 

The logic is correct. If when your Flow run, the screen is blank, you can exist the Flow to My Flow list, click the Flow, then click the run history. Or you could test Flow using data from previous runs.

Annotation 2019-10-03 153822.png

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

Dual Super User
Dual Super User

Re: Update or create new item in Sharepoint from form

Several specific issues I see.

1) Can you show the advanced settings for the Get items?  I assume you are filtering at this point for the specific user who created the Form response.

2) I don't see the point of creating the array of titles.  If your get items is filtering then you should get either one or no items back, not multiples.

3) Why are you comparing length() to something from the Forms?  The idea would be to try to retrieve the specific list item where Title equals the name of the submitter of the Form.  If found, length() > 0, then update a record, if not create a new one. I don't see what this comparison accomplishes.

4) Why in condition 2 are you comparing Link to Created by? Since you are creating your records via FLOW the created by will be the account running the Flow, so there will never be a match unless you report your availability.



-------------------------------------------------------------------------
If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.
dm_elementwa
Level: Powered On

Re: Update or create new item in Sharepoint from form

The flow was turned off, hence the blank screen. Since turning back on, I was able to run the flow which has now helped to identify where the error is. Thank you! 🙂

 

So here's where the error is:

Screen Shot 2019-10-04 at 9.06.31 am.pngScreen Shot 2019-10-04 at 9.06.42 am.png

Dual Super User
Dual Super User

Re: Update or create new item in Sharepoint from form

This is why in my sample I based my comparison against the email address rather than the given name.  It looks from the error like someone has a special character in their name which is interferring with the JSON.



-------------------------------------------------------------------------
If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.
dm_elementwa
Level: Powered On

Re: Update or create new item in Sharepoint from form

Yes, there is one staff memeber that has a hyphenated surname. Would this cause the interference? If so, would I get around this by using the email address comparison?

Dual Super User
Dual Super User

Re: Update or create new item in Sharepoint from form

It wasn't a hypen I saw.  It looked like someone had an apostrophe in their surname.  Single quotes are used to set things off in JSON so to pass them as a value they need to be escaped, a single quote passed to JSON should be ''. If you have a person whose name is something like O'Brien that will throw off the JSON.  Emails don't allow the use of ' in an email address.



-------------------------------------------------------------------------
If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.

Helpful resources

Announcements
thirdimage

Power Automate Community User Group Member Badge

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

firstImage

Incoming: New and improved badges!

We've given our badges an overhaul and also added some brand new ones!

fifthimage

Microsoft Learn

Learn how to build the business apps that you need.

sixthImage

Power Platform World Tour

Find out where you can attend!

seventhimage

Webinars & Video Gallery

Watch & learn from the Power Automate Community Video Gallery!

Top Kudoed Authors (Last 30 Days)
Users online (6,320)