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

Create item and update item

Hi,

 

I'm trying to make a flow in which when an item is created or modified from List 1 it creates List 2 but if List 1 I would like for List 2 to update.

 

Right now when I modify list 1 it creates a duplicate in list 2 and I dont want that. I want for the one in list 2 to update only.

11 REPLIES 11
Dual Super User
Dual Super User

Re: Create item and update item

Hi @karlagb20 

 

Can you please post a screenshot of the current flow? 

 

You can use the Update Item in sharepoint action to update the item in list 2 whenever an item is updated in List 2. 

 

You can add a get items action after the trigger and modify the filter query to get the items that match some unique value in List 2 from List1. Only if there is a match you will get just one value and you can update it in case of updating and the item already exists. Now if the item is new, you can check the length of the items retrieved in the get items and if it is 0 create a new item in list 2. (Makes sense?)

 

Hope this Helps!

 

If this reply has answered your question or solved your issue, please mark this question as answered. Answered questions helps users in the future who may have the same issue or question quickly find a resolution via search. If you liked my response, please consider giving it a thumbs up. THANKS!

Super User
Super User

Re: Create item and update item

@karlagb20 

I agree with @yashag2255 - he  mentioned that you need to be able to identify items in list 2 that relate to items in list 1.  I suggest adding a column to list 2 where you'll store the ID of the item from list 1.  That will make it easy to identify what item in list 2 should be updated when an item in list 1 is updated via the filter query/OData filter.

 

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

Scott
karlagb20
Level: Powered On

Re: Create item and update item

@yashag2255 @ScottShearer 

 

can you please show me how that would look? This is what I have so farflow.PNG

Super User
Super User

Re: Create item and update item

@karlagb20 

Please see my screen shots below.

I use two lists - List A and List B.  I added a column to ListB called ListAID to store the ID of the corresponding entry in List A.  The column that I added is a number with zero decimals.

My GetItems action for ListB uses a Filter Query so that only items that correspond to to the entry in ListA are returned (there should either be one or none).  Note the single quotes around the ID in the filter query.

 

If no items are returned, I create a new item.

If there is an item returned, I update that item.

SyncLists1.jpgSyncLists2.jpg

 

 

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

Scott
karlagb20
Level: Powered On

Re: Create item and update item

@ScottShearer Can you show how the flow will look if I have to only create items from List A to list B if the field Location equals "Florida".

 

I only want list B to get items from list A that have the location field set as "Florida"

Super User
Super User

Re: Create item and update item

@karlagb20 :

 

To limit to entries where the location field is Florida, simply add the following to the filter query:

and Location eq 'Florida'

 

LocFilterQuery.jpg

 

If you don't want to create items unless the Location is Florida, you'll want to put in a condition that cheks for that at the top of your Flow - if the lcoation ins't Florida then exit your Flow with a Control Terminate action.  So, if no entries exist other than those in Florida, you don't need to check for that in your filter query - it can stay unchanged.

 

 

 

 

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

Scott
ktmbob
Level: Powered On

Re: Create item and update item

Hi @ScottShearer ,

I am pretty sure I have done everything correctly in my flow:

 

List A - 41G Schedule

List B - 41G Monthly

 

I have added the column (number w/ 0 decimals) to List B called 41GScheduleID to capture List A ID.

 

The error I get in the flow is this:

BadRequest

"status": 400,
"message": "The expression \"41GScheduleID eq '282'\" is not valid.\r\nclientRequestId: ec554315-3b7a-4e6b-b82c-6e3884ea0580\r\nserviceRequestId: ec554315-3b7a-4e6b-b82c-6e3884ea0580"

 

...and its in the Get Items part.

 

My flow:

flow1_1.JPGflow2_1.JPG

 

Any ideas?  Thanks.

Super User
Super User

Re: Create item and update item

@jtmbob :
Remove the quotes around the number (282) - no quotes for numbers.

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

Scott
ktmbob
Level: Powered On

Re: Create item and update item

Hi @ScottShearer ,

Thanks for the quick reply. 

 

I tried that and now got the following error still in the 'Get items' part:

 

{
"status": 400,
"message": "The expression \"41GScheduleID eq 291\" is not valid.\r\nclientRequestId: 7a4dfcbf-bcd0-439f-b172-bb874c10f43c\r\nserviceRequestId: 7a4dfcbf-bcd0-439f-b172-bb874c10f43c"
}

 

 

ktmbob
Level: Powered On

Re: Create item and update item

Changed a couple things and it worked!

 

I abandoned trying to filter by ID number and moved to 'Job Title' like this:

 

flow4.JPG

 

The condition checked for the Job Title as empty (0) and was written like this: equals(length(body('Get_items')?['value']), 0)

 

Please also note that the space in between Job and Title must be replced with _x0020_ .

 

Works perfectly.  Thanks to all above for the help!

ktmbob
Level: Powered On

Re: Create item and update item

Ugh.  Not fully resolved.

My workaround only partially works.  If I sort by title, two bad things can occur:

1.  If there is an update that includes a change in title I get a new entry on the destination calendar

2. If there is a duplicate title (ex: "vacation"), then I get an overwrite condition and I lose an entry

 

Clearly I need to figure out how to use the ID in the Filter Query due to the uniqueness of the ID number.

 

As mentioned above, I have tried to make the new column both a text and number column and respectively inserting the single quotes around the dynamic content ID symbol in the filter query entry.

 

I have also tried both equals(length(body('Get_items')?['value']), 0) and empty(body('Get_items')?['value']) 'is equal to' 'true' as the condition

 

Here is the error:

flow3_1.JPGflow3_2.JPG

I apologize for the wasted pixels if this is unnecessary, but here is the info from the headers box:

X-SharePointHealthScore 1
X-MS-SPConnector 1
X-SP-SERVERSTATE ReadOnly=0
DATASERVICEVERSION 3.0
SPClientServiceRequestDuration 103
SPRequestGuid 174b9329-9aa1-4bdd-9733-2da595b12a88
request-id 174b9329-9aa1-4bdd-9733-2da595b12a88
MS-CV KZNLF6Ga3UuXMy2llbEqiA.0
Strict-Transport-Security max-age=31536000
X-FRAME-OPTIONS SAMEORIGIN
MicrosoftSharePointTeamServices 16.0.0.9124
X-Content-Type-Options nosniff
X-MS-InvokeApp 1; RequireReadOnly
Timing-Allow-Origin *
x-ms-apihub-cached-response false
Cache-Control max-age=0, private
Date Thu, 15 Aug 2019 23:21:55 GMT
P3P CP="ALL IND DSP COR ADM CONo CUR CUSo IVAo IVDo PSA PSD TAI TELo OUR SAMo CNT COM INT NAV ONL PHY PRE PUR UNI" X-AspNet-Version
4.0.30319 X-Powered-By ASP.NET 
Content-Length 200
Content-Type application/json
Expires Wed, 31 Jul 2019 23:21:56 GMT
Last-Modified Thu, 15 Aug 2019 23:21:56 GMT
 
Body text:
"status": 400,
"message": "The expression \"41G_ID eq 320\" is not valid.\r\nclientRequestId: 174b9329-9aa1-4bdd-9733-2da595b12a88\r\nserviceRequestId: 174b9329-9aa1-4bdd-9733-2da595b12a88"
 
Any help would be greatly appreciated.

Helpful resources

Announcements
firstImage

Power Platform Online Conference

Speakers, submit your sessions now! Call for speakers ends Feb. 10!

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!

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 (4,870)