cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Letish
Advocate I
Advocate I

Compare SharePoint list field to MYSQL record field

Hello all,

 

I am having issues creating a flow. Let me explain. I have a MYSQL table with information on cleaning activities linked to a property management system. I have a Sharepoint list that has columns for some of the information from each cleaning activity as well as fields to assign the clean to a user and a Yes/No field for clean complete. I am linking the SharePoint list to a PowerApp. 

 

The flow I have designed pulls the information from the Database with Get Tables then Get Rows. It then pulls information from the SharePoint list with Get Items. I want to then compare the Activity number in the table with the Activity number in the SP list. A condition then gives a result based on that comparison. If they match I would like the record in the SP list to be updated. If there is no corresponding Activity number in the SharePoint list I would like the record to be created.

 

When I try to make this flow a second Apply To Each appears automatically. When I run the flow it seems to compare each Activity number in excess of ten times each and I end up with way too many records. I think I am making an error in the comparison but I am unsure how to resolve it.

 

Any help would be appreciated

 

 

Pic 1

Pic 2

Pic 3

Pic 4

 

 

1 ACCEPTED SOLUTION

Accepted Solutions

Maybe try doing it this way: for each record from SQL do a call to SharePoint (so put "Get items" in the first for each), but define odata filter: activity_id eq 'sql_activity_id', where acitivity_id is internal name of the column in SP and replace sql_activity_id with dynamic outcome from get rows.

Then check, if number of returned rows is higher than 0.

If yes, do another for each (on data from SP) and update ich record. If not, create record in SP.

 

Regards,

Tomasz

View solution in original post

7 REPLIES 7

Hi!

 

So basically what you want to achieve is to update every SharePoint item that has activity_id matching any record from SQL and for those records in SQL that don't have corresponding entries in SharePoint, create entries in SP?

 

Regards,

Tomasz

Maybe try doing it this way: for each record from SQL do a call to SharePoint (so put "Get items" in the first for each), but define odata filter: activity_id eq 'sql_activity_id', where acitivity_id is internal name of the column in SP and replace sql_activity_id with dynamic outcome from get rows.

Then check, if number of returned rows is higher than 0.

If yes, do another for each (on data from SP) and update ich record. If not, create record in SP.

 

Regards,

Tomasz

View solution in original post

Hi Tomasz,

 

Yes, that is exactly what I want to do but I don't know how to leave the "create sharepoint item" until the particular MYSQL record has been checked against every SP item. The way I make the flow creates a SP record every time there isn't a match rather than if there is no match overall. 

 

Any help would be great. 

That makes so much sense. How do I check the number of returned rows? I tried with length( ) but my syntax was wrong. 

I feel like I am a step closer but not quite there yet.

 

  • Am I checking for the number of row returned from Get Rows within the loop? So far it matches the row count each time with no filtering

AfterTomasz help.png

Exactly! You're almost there. Now build condition, to check if number of rows matching that activity_id in SharePoint is greater than 0. If yes - update them all. If not - create new one:

 

TPoszytek_1-1606947932001.png

 

Inside the condition use the below expression: 

length(outputs('Get_items')?['body/value'])
 
Regards,
Tomasz

 

That odata query should work. I mean - it's syntax is correct. Just be sure that SharePoint activityID column's internal name is the one you used. But I guess you did that already 🙂

Helpful resources

Announcements
MPA_User Group Leader_768x460.jpg

Manage your user group events

Check out the News & Announcements to learn more.

V3_PVA CAmpaign Carousel.png

Community Challenge - Giveaways!

Participate in the Power Virtual Agents Community Challenge

Carousel 2021 Release Wave 2 Plan 768x460.jpg

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

R2 (Green) 768 x 460px.png

Microsoft Dynamics 365 & Power Platform User Professionals

DynamicsCon is a FREE, 4 half-day virtual learning experience for 11,000+ Microsoft Business Application users and professionals.

Users online (2,143)