cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Anonymous
Not applicable

SharePoint Flow - modify list item or create new if doesn't exist

Hey,

As you can see in the picture below, initally, I am using the trigger 'When file is created or modified (properties only)".  I need a condition to tell whether a file is being created up merely updated.  If it is new, then it will use the 'Yes' section and create a new item.  If a file is just being modified, then it will update the list item. But, I do not know how to set up the condition to do this?

 

Thanks!

 

create_or_modify.png

6 REPLIES 6
Community Support Team
Community Support Team

Re: SharePoint Flow - modify list item or create new if doesn't exist

Hi @Anonymous,

 

Yes, it can be achieved by using a Condition to check if the Created time and Modified time are equal.


If they are equal, then the file is new. While if they are not equal, then the file is being modified.


From the screenshot, it seems that you are trying to create/update item in a SharePoint List. When using the “Update item” action, you will be asked to specify the Id for the item.


To get the Id field, you could consider using the action “Get items”, then adding a Condition to filter the one that is required.


Please take the following screenshot for a reference.

3.PNG


If you need more help, please feel free reply.

 

Best regards,
Mabel Mao

Community Support Team _ Mabel Mao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
mjhufford
Level: Powered On

Re: SharePoint Flow - modify list item or create new if doesn't exist

I've found that this is not always accurate (although I'm not sure why).  I have records with only 1 version where the created and modified time stamps differ by several milliseconds. I've had to modify my flow to check if they're within a few seconds of one another, which doesn't feel like a great solution.  Would love something more iron clad. 

mjhufford
Level: Powered On

Re: SharePoint Flow - modify list item or create new if doesn't exist

I ended up changing my flow so that I look at the version of the item.  If it is 1.0, then it's new...otherwise it's being modified.  Versioning must be enabled for this to work.

 

2018-11-15_10-41-55.pngHTTP Request to get version and store it in a string variable2018-11-15_10-45-14.pngCompare the string variable value with '1.0'

misssp
Level: Powered On

Re: SharePoint Flow - modify list item or create new if doesn't exist

@mjhufford

 

I am trying your suggestion. But, The condition in my Flow does not have  'Edit in Advanced Mode' .  I wonder if it is because the site is on SharePoint online 2013 but not SharePoint online 2016.  I am stuck in the last step.  

I really hope to see that your suggestion works for me.  Thanks.

 

Initialize_Variable.PNG

misssp
Level: Powered On

Re: SharePoint Flow - modify list item or create new if doesn't exist

Testing with different tenant sharepoint site - I believe this is in SharePoint 2016 - 'Condition' has 'Edit in advanced mode'.  But, when I tried to save the flow.

Got error: The template validation failed: 'The action(s) 'SPRest-Verison' referenced by 'inputs' in action 'Initialize_variable' are not defined in the template.'.

 

SP2016_Initialize_Variable_save_error.PNG

mjhufford
Level: Powered On

Re: SharePoint Flow - modify list item or create new if doesn't exist

I'm not sure about that one.  Sorry.

Helpful resources

Announcements
firstImage

Better Together Contest Finalists Announced!

Congrats to the finalists of our ‘Better Together’-themed T-shirt design contest! Click for the top entries.

firstImage

Incoming: New and improved badges!

Look out for new contribution recognition badges coming SOON!

firstImage

New & Improved Power Automate Community Cookbook

We've updated and improved the layout and uploading format of the Power Automate Cookbook!

thirdimage

Power Automate Community User Group Member Badge

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

sixthImage

Community Summit North America

The top training and networking event across the globe for Microsoft Business Applications

Top Solution Authors
Top Kudoed Authors
Users online (3,822)