cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
YCOXYLO
Regular Visitor

Update item Sharepoint without apply to each

Dear all,

 

Thank you for your time and effort in advance.

I am in dire need of your assistance.

 

I want to update my sharepoint list with company information based on the replies i get via MS Forms.

In order to do this i have set up a condition query that focuses on two conditions;

- If the Company ID MS Forms = Company ID

- Sharepoint and Relation MS Forms = Relation Sharepoint

If true, then update item sharepoint, if false then create item sharepoint.

 

My problem is the Apply to each function when making use of Dynamic content for it will either create more then needed or will change every item instead of 1 desired item in my sharepoint list.

During the Update Item phase I am forced to use ID2 (unique identiefier) which triggers the Apply to Each.

Is there anyway i can avoid this apply to each? Please help.

 

See my flow below. Thank you.

Snap1.pngSnap2.pngSnap3.png     

3 ACCEPTED SOLUTIONS

Accepted Solutions
Expiscornovus
Super User
Super User

Hi @YCOXYLO,

 

To avoid the apply to each action you can use expressions. I am assuming your get items will only have one result? 

 

If so, you can use an index [0] or a first function to retrieve the ID of the first item.

 

Below is an example of that approach.

 

 

outputs('Get_items')?['body/value'][0]['ID']

 

 

firstitem_getitems.png

View solution in original post

Expiscornovus
Super User
Super User

Hi @YCOXYLO,

 

If you want to check if the company already exists in the list I would use a Filter Query. Something like CompanyId eq 'CompanyID'. That one between is quotes is the Microsoft Forms question field.

 

This way you will only retrieve the CIM Response item from that specific company. 

 

filterquery_companyid.png

View solution in original post

YCOXYLO
Regular Visitor

Hi @Expiscornovus,

 

A normal filter query in this case would not be optionable because the to be created items also have to be taken in account for this flow. After a lot of headaches and rethinking i found the solution, based on your Filter Query option.

 

Instead of having 1 flow containing a Create item option and a update item option I decided to split them up in 2 flows and it works! 1 flow for create and 1 flow for update, each having there own Filter query in order to funnel out only the requested data so that 1 item will be changed or created.

 

Again, thank you for all your aid and assistance in this matter but above all tahnk you for your time and patience. I could not have done it without you.

View solution in original post

7 REPLIES 7
Expiscornovus
Super User
Super User

Hi @YCOXYLO,

 

To avoid the apply to each action you can use expressions. I am assuming your get items will only have one result? 

 

If so, you can use an index [0] or a first function to retrieve the ID of the first item.

 

Below is an example of that approach.

 

 

outputs('Get_items')?['body/value'][0]['ID']

 

 

firstitem_getitems.png

View solution in original post

YCOXYLO
Regular Visitor

@Expiscornovus Thank you so much for this! I thought i got ecerything figured out but this one issue kept me going on for hours 😄

 

You are my hero of the day! Thank you so much!

YCOXYLO
Regular Visitor

@Expiscornovus 

I am afraid i acted too hastly. After checking in on the effects it worked out fine in the beginning but after a further analysis I found out that the Update item is now only updating the very first item and the first item only when changes occur.Create a new item (works)Create a new item (works)Tried to change 3rd item, but 1st was changed insteadTried to change 3rd item, but 1st was changed instead

 

How can i make the Update item work in a way that it will search for the correct ID (in this case for example item number 3 and change that required list row alone without effecting the others?

 

Thank you

 

Expiscornovus
Super User
Super User

Hi @YCOXYLO,

 

Just to double check.

 

Both line 1 and line 3 have the same company ID (3000). How is the Get items configured that it knows it needs to retrieve line number 3? In other words, what kind of filter query are you using to support this scenario?

YCOXYLO
Regular Visitor

@Expiscornovus 

 

Thank you again with you assistance in advance.

 

So here is what i want to achieve:

 

Below is my Sharepoint list.

Snap1.png

Right now i typed down an example of 5 companies with each company having there own Company ID and type of Relation (Accounting, Legal or Legal & Accounting). After i sent out emails to companies they can reply to me via MS Forms. Based on the response flow will have to determine if a new company has to be added (create item) to the sharepoint list (example company 06, yet to be added) or if one of the already present companies information has to be updated (Update item). In order to achieve this i created the below flow.

Snap2.pngSnap4.pngSnap5.png

 

Snap6.png

Now i also want to update already present companies in my list with changed information. Example: Company 05 changed its name to 'tester'. In this case i want to update that information with this flow as well.

Is this possible?

Snap3.png

Hope this is more clear.

 

Thank you

Expiscornovus
Super User
Super User

Hi @YCOXYLO,

 

If you want to check if the company already exists in the list I would use a Filter Query. Something like CompanyId eq 'CompanyID'. That one between is quotes is the Microsoft Forms question field.

 

This way you will only retrieve the CIM Response item from that specific company. 

 

filterquery_companyid.png

View solution in original post

YCOXYLO
Regular Visitor

Hi @Expiscornovus,

 

A normal filter query in this case would not be optionable because the to be created items also have to be taken in account for this flow. After a lot of headaches and rethinking i found the solution, based on your Filter Query option.

 

Instead of having 1 flow containing a Create item option and a update item option I decided to split them up in 2 flows and it works! 1 flow for create and 1 flow for update, each having there own Filter query in order to funnel out only the requested data so that 1 item will be changed or created.

 

Again, thank you for all your aid and assistance in this matter but above all tahnk you for your time and patience. I could not have done it without you.

View solution in original post

Helpful resources

Announcements
UG GA Amplification 768x460.png

Launching new user group features

Learn how to create your own user groups today!

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

Welcome Super Users.jpg

Super User Season 2

Congratulations, the new Super User Season 2 for 2021 has started!

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.

Top Solution Authors
Users online (2,485)