cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
OliverR-82
Helper IV
Helper IV

Use a nested outputs in expression

Hi everyone,

I've been breaking my head over this for days and can't seem to find a way to get it to work. I will try my best to explain the setup and what it is I need to do.

I have a SharePoint list 'Requests' that has a number of date fields (among other fields). The list accepts different content types ie. different types of requests. Based on the type of request (ie. content type of the list item), different date fields in the list need to be filled in automatically based on the request date. 

There is a second SharePoint list 'DateCalculations' that contains the fields that need to be calculated for each type of request (ie. content type). 

Content TypeFieldToCalculateBaseFieldNumberOfDays
General requestFieldXRequestDate30
General requestFieldYRequestDate20
General requestFieldZRequestDate5
Urgent requestFieldXRequestDate15
CommentFieldACommentDate10

I'm using fictional data here, the lists are actually for something else entirely but this is just to give you an idea. Important to note here is that:

  • For each content type there are one or multiple fields that need to be calculated 
  • The fields that need to be calculated are not the same for all content types
  • The base fields are not the same for all content types

Now suppose a General request is added to the SharePoint list (ie. an item of content type 'General request'. For that item I need to calculate 3 different dates that are all based on the request date (ie. the date the item was added to the list).

What I've done so far:

OliverR-82_0-1608578725082.png

The Get Items action gets me the list items of the 'DateCalculations' list that match the content type of the newly created item. So far, so good. Next, I need to cycle through that array, and for each item in that array get the specified basefield from the 'Requests' list, add the specified days to it, and update the item. My problem is with the bold underlined part: getting the basefield from the 'Requests' list.

If I were to write it in an expression it would look like this:

 

triggerOutputs()?['body/outputs('GetDateCalculations')?['body/BaseField']']

 

 To break this down, this basically means "get me the value of triggerOutputs (ie. the item that was added) where the fieldname equals the value of the 'GetDateCalculations' action". I would stick this is an Apply to Each action that loops over all the fields in the array that matches the content type of the added item.

OliverR-82_1-1608579266955.png

If I could get that value in a variable I could then use it to perform calculations on it and update it.

The problem is that that expression is not valid. So my question is: how can I get this to work?

I hope that my question is clear and that someone here has an idea of how to get around this. Any help would be greatly appreciated as always.

And in case you are wondering why I am not simply doing this via calculated fields within the SharePoint lists, the answer is because I need this to be flexible for the customer. The idea is if the procedure changes and the number of days for the different types of requests need to be updated, it can simply be done by changing the values in the DateCalculations list rather than editing the formulas for all the calculated dates.

1 ACCEPTED SOLUTION

Accepted Solutions
annajhaveri
Super User
Super User

Hello @OliverR-82 , please try below expression

triggerBody()?[items('Apply_to_each')?['BaseField']]

 

Regards,
Anna Jhaveri

If I have answered your question, please mark the post as Solved to help other users to identify the correct answer
If you like my response, please give it a Thumbs Up.

View solution in original post

2 REPLIES 2
annajhaveri
Super User
Super User

Hello @OliverR-82 , please try below expression

triggerBody()?[items('Apply_to_each')?['BaseField']]

 

Regards,
Anna Jhaveri

If I have answered your question, please mark the post as Solved to help other users to identify the correct answer
If you like my response, please give it a Thumbs Up.

View solution in original post

Hi @annajhaveri ,

You're right, that works. Thank you for the help!

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.

Top Solution Authors
Users online (2,335)