Skip to main content

Notifications

Power Automate - General Discussion
Unanswered

Create item and update item

(0) ShareShare
ReportReport
Posted on by

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.

Categories:
  • ktmbob Profile Picture
    ktmbob 14 on at
    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.
  • ktmbob Profile Picture
    ktmbob 14 on at
    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 Profile Picture
    ktmbob 14 on at
    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"
    }

     

     

  • ScottShearer Profile Picture
    ScottShearer 25,150 on at
    Re: Create item and update item
    @jtmbob :
    Remove the quotes around the number (282) - no quotes for numbers.

  • ktmbob Profile Picture
    ktmbob 14 on at
    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.

  • ScottShearer Profile Picture
    ScottShearer 25,150 on at
    Re: Create item and update item

    @Anonymous :

     

    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.

     

     

     

     

  • 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"

  • ScottShearer Profile Picture
    ScottShearer 25,150 on at
    Re: Create item and update item

    @Anonymous 

    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

     

     

  • 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

  • ScottShearer Profile Picture
    ScottShearer 25,150 on at
    Re: Create item and update item

    @Anonymous 

    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.

     

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Microsoft Kickstarter Events…

Register for Microsoft Kickstarter Events…

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Announcing Forum Attachment Improvements!

We're excited to announce that attachments for replies in forums and improved…

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 145,475

#2
RandyHayes Profile Picture

RandyHayes 76,287

#3
Pstork1 Profile Picture

Pstork1 64,767

Leaderboard