Skip to main content

Notifications

Community site session details

Community site session details

Session Id :
Power Automate - Using Flows
Answered

Prevent Duplicate in SharePoint using Composite Key when saving from a Powerapps Collection

(0) ShareShare
ReportReport
Posted on by

Hi Power Automate community:

I have a collection generated within PowerApps and I would like to save the records to SharePoint ensuring there are no duplicates.  In the SharePoint  list I created a calculated field called "Composite" which consists of 2 fields separated  by a pipe "l".

 

The following is the Automate flow I have been trying generates the following error:

 InvalidTemplate. Unable to process template language expressions in action 'Get_items' inputs at line '1' and column '2874': 'The template language expression 'json(decodeBase64(triggerOutputs().headers['X-MS-APIM-Tokens']))['$connections']['shared_sharepointonline']['connectionId']' cannot be evaluated because property 'shared_sharepointonline' doesn't exist, available properties are ''. Please see https://aka.ms/logicexpressions for usage details.'.

The Automate Flow has the following components:

 

Can someone assist me with correcting this  flow please.

 

Barry

 

 

  • Verified answer
    v-bacao-msft Profile Picture
    on at
    Re: Prevent Duplicate in SharePoint using Composite Key when saving from a Powerapps Collection

     

    Hi @Anonymous ,

     

    I'm glad to help you.

     

    If so, please click "Accept as Solution" on the reply that describes how you were able to solve your issue!

     

    This makes your post much easier for other members of the community to see and find when looking for a solution!

     

    Best Regards,

  • Community Power Platform Member Profile Picture
    on at
    Re: Prevent Duplicate in SharePoint using Composite Key when saving from a Powerapps Collection

    OK - As suggested I changed the order of the comparison items in the Filter Array and - BINGO! it works - no duplicates.  This is fantastic work - I am so indebted to you for your excellent knowledge and support.  Thank you so very much

     

    Barry

  • Verified answer
    v-bacao-msft Profile Picture
    on at
    Re: Prevent Duplicate in SharePoint using Composite Key when saving from a Powerapps Collection

     

    Hi @Anonymous ,

     

    I looked at these two tables and thought that my previous method should work. You just need to replace the fields in the Filter array that you want to compare with Composite Key.

     

    Or have you considered avoiding this problem from the data source? Is there a function in PowerApps that can remove the same records, then there will be no duplicate records in the collection. Perhaps this is also a solution.

     

    Best Regards,

  • Community Power Platform Member Profile Picture
    on at
    Re: Prevent Duplicate in SharePoint using Composite Key when saving from a Powerapps Collection

    Dear  

     

    AuditDindingsTEST.png

    Note the Composite column has duplicate values - therefore duplicate records

    Can you advise how we can stop the Duplicate being saved to SharePoint

    Many thanks 

    Barry

  • v-bacao-msft Profile Picture
    on at
    Re: Prevent Duplicate in SharePoint using Composite Key when saving from a Powerapps Collection

     

    Hi @Anonymous ,

     

    Adding Compose to Apply to each is to add two branches, it is only used as a transition, it does not matter what is filled in the Input.

    In addition, you can check my screenshot again and add two branches to Apply to each, instead of outside of Apply to each.

    I have shown the details of each branch, and the main structure is shown in Apply to each.

    Please try again.

     

    Best Regards,

  • Community Power Platform Member Profile Picture
    on at
    Re: Prevent Duplicate in SharePoint using Composite Key when saving from a Powerapps Collection

    Again thank you for your response 

    I rebuilt the flow as you suggested but it now fails at Get Items 2.  Can you please check that I have created the elements correctly:

    Flow6.png

  • v-bacao-msft Profile Picture
    on at
    Re: Prevent Duplicate in SharePoint using Composite Key when saving from a Powerapps Collection

     

    Hi @Anonymous ,

     

    It seems that you only need to add the PowerAPPS button as a trigger to the method I provided.

     

    I follow the method provided by the screenshot of your previous Flow configuration. The configuration on the Parse JSON action should be the same.

    To parse the records in the collection and then use the Filter array to filter, you need to replace the Title field with the field you want to compare.

    Finally, determine whether to add or change items.

     

    Hope that makes sense.

     

    Best Regards,

  • Community Power Platform Member Profile Picture
    on at
    Re: Prevent Duplicate in SharePoint using Composite Key when saving from a Powerapps Collection

    Hi 

    Thank you for your continued response - No the Trigger is a button from Powerapps not "item is newly created or changed".   It would be better if I could use "When Item is created or change" but I did not know how to compare my powerapps collection with my SharePoint List with "When Item is created or change" trigger.  So can demonstrate using the elements of my flow what you have in mind? 

  • v-bacao-msft Profile Picture
    on at
    Re: Prevent Duplicate in SharePoint using Composite Key when saving from a Powerapps Collection

     

    Hi @Anonymous ,

     

    So, is the condition triggered by Flow that the item is newly created or changed?

    If so, you only need to add When an item is created or modified as a trigger in the method mentioned in my last reply.

    Please take a try.

     

    Best Regards,

  • Community Power Platform Member Profile Picture
    on at
    Re: Prevent Duplicate in SharePoint using Composite Key when saving from a Powerapps Collection
    • v-bacao-msft

    Hi again,

    Perhaps it will be better if I use an auto SharePoint trigger "When a new item is created or modified" rather than a PowerApps button.

    If so, I do not know how to setup the Flow for this.  Could you help with creating the Flow - Barry

     

     

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

🌸 Community Spring Festival 2025 Challenge 🌸

WIN Power Platform Community Conference 2025 tickets!

Markus Franz – Community Spotlight

We are honored to recognize Markus Franz as our April 2025 Community…

Kudos to the March Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 146,660 Most Valuable Professional

#2
RandyHayes Profile Picture

RandyHayes 76,287 Super User 2024 Season 1

#3
Pstork1 Profile Picture

Pstork1 66,004 Most Valuable Professional

Leaderboard

Featured topics

Restore a deleted flow