web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / Prevent Duplicate in S...
Power Automate
Unanswered

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

 

 

Categories:
I have the same question (0)
  • ChristianAbata Profile Picture
    8,951 Most Valuable Professional on at

    To prevent duplicate data in sharepoint you can edit your Column to enforce yes.

    unique.png

  • Community Power Platform Member Profile Picture
    on at

    Thank you for your response but I wish to prevent duplicates across two columns in SharePoint.  I have created a calculated field that combines the 2 columns but it is impossible to have this calculated field as "Unique" in SharePoint.  That is why I am resorting to Flow.  If you have a Flow solution for this I would be please to see it.  The following is my flow elements that generate the error

    Flow5.png

     

  • ChristianAbata Profile Picture
    8,951 Most Valuable Professional on at

    @Anonymous oh maeby what you want is this

    Try with Union(Array,Array) Thats get only the diferent values from array.

    See this solution to get more details.

    https://powerusers.microsoft.com/t5/General-Power-Automate/microsoft-flow-get-all-items-with-distinct-Assigned-to-User-and/m-p/114429#M42528

  • Verified answer
    v-bacao-msft Profile Picture
    on at

     

    Hi @Anonymous ,

     

    For InvalidTemplate errors, you could refer to this similar thread:

    https://powerusers.microsoft.com/t5/General-Power-Automate/Flow-Error/td-p/352714

     

    Also about Prevent Duplicate in SharePoint, you can refer to the following method.

    You can add a parallel branch to handle the two cases of Update item and Create new item.

    114.PNG

    Update item:

    115.PNG

    Create item| Use the Filter array to determine if there are already eligible items in the List. Use the length() function to get the number of items filtered by the Filter array. If 0, create a new item.

    116.PNG

    Replace Title with the field you want to compare.

    Hope this helps.

     

    Best Regards,

  • Community Power Platform Member Profile Picture
    on at

    Many thanks for your incisive response _ I will give it a try  and advise 

     

    Barry

  • Community Power Platform Member Profile Picture
    on at

    Also I checked my PowerApps button OnSelect command

    SaveAuditCompileToFindings.Run(JSON(AuditInfoComposite))

     

    This command registers an error in PowerApps as follows: 

    1st Error = Invalid number of arguments - received 1 expected 2

    2nd Error = Invocation of unknown or unsupported function

  • Community Power Platform Member Profile Picture
    on at
    • 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

     

     

  • v-bacao-msft Profile Picture
    on at

     

    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

    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

     

    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,

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

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Automate

#1
Michael E. Gernaey Profile Picture

Michael E. Gernaey 522 Super User 2025 Season 2

#2
Tomac Profile Picture

Tomac 364 Moderator

#3
abm abm Profile Picture

abm abm 243 Most Valuable Professional

Last 30 days Overall leaderboard