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 Type | FieldToCalculate | BaseField | NumberOfDays |
General request | FieldX | RequestDate | 30 |
General request | FieldY | RequestDate | 20 |
General request | FieldZ | RequestDate | 5 |
Urgent request | FieldX | RequestDate | 15 |
Comment | FieldA | CommentDate | 10 |
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:
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:
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.
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.
Solved! Go to Solution.
Hello @OliverR-82 , please try below expression
triggerBody()?[items('Apply_to_each')?['BaseField']]
Hello @OliverR-82 , please try below expression
triggerBody()?[items('Apply_to_each')?['BaseField']]
User | Count |
---|---|
92 | |
45 | |
21 | |
18 | |
16 |
User | Count |
---|---|
136 | |
49 | |
42 | |
36 | |
28 |