Problem creating document from SharePoint list

Hello,

I am trying to generate a monthly report (in ppt) from the content of a SharePoint list. I would like the ppt split into sections per team and then populate a table with the tasks undertaken by that team. I am able to create a JSON table with tasks no problem, but I am not sure how to add a list of tasks within each of the teams in JSON. Essentially I am creating an array of arrays from what I can tell, though I can't create this using Append to Array variable.


Please help!

best regards,

Phil

Hi Phil! Could you share JSON raw outputs of this action?

изображение

I need just its structure so you can replace the live data with some dummy values. Also, please share a sample of the result PowerPoint presentation you would like to get at the end of the day and will try to think out the solution for your case.

Hi Evgeniy,

Thanks for your prompt reply.

I have a SharePoint list which looks something like:

Normally there would be Jan-Dec, but I have only kept Jun/Jul/Aug. This list is being used as a basic annual workplan so it collects progress against deliverables for months which have passed and planned work (priorities) for future months. When a month passes, staff update the planned work with actual work.

On a monthly basis I would like to produce a report. So this month (July) I would like to produce a report where I generate a ppt slide or page (if PDF, doc etc) per Work Programme with a table containing the following columns:

  • deliverable
  • person responsible
  • status
  • last month update (jun column)
  • this month priorities(jul column).

In the PPT this would therefore look something like:

Slide 1: Data Systems

  • Person 1 - Infrastructure Engineer - (Insert photo)
  • Person 2 - Data Architect - (Insert photo)
  • Person 3 - Database Management Officer - (Insert photo)

Slide 2: Management

  • Person 4 - Manager - (Insert photo)
  • Person 5 - Finance Officer - (Insert photo)

If its not too much, there are two other things I am trying to do:

  1. To select last month/this month - I need a function which gets the current date and calculates last month and this month to determine which column to use (i.e Jun and Jul as of today)
  2. At the top of each page, or on a cover page prior to the table associated with the team, I would like to put a summary of each team - i.e extract the Name, Job Title and photo from the Responsible column which are office 365 user objects. (I have added an example of this above each team table above)

Does this make sense?

Thanks so much!

Phil

Hello Phil! I just hope that I understood your use case and requirements right because configuring this automation took a while.

So, I reproduced the provided data structure in a SharePoint list. The 'Status' and 'Work prgoramme' are choice columns because I assumed that you have restricted and pre-defined options there.

Then, I created a Plumsail process for a PowerPoint template. This format has a restriction in processing images: you need to put a picture-placeholder and define a token in its alternative text. Thus, you need to know beforehand what number of pictures you will have in the presentations. In your case it is not possible so I just drop this part and add only names and job titles to a separate slide to overview the team for a current programme. If you use a Word template, the pictures can be added dynamically too. The PPTX template is attached.

template.pptx (152.8 KB)

Then I created a Power Automate flow started manually. First, I initialised four array variables, three of them are empty and one contains the possible options in the 'Work programme' field.

The next step is to iterate over each item in the 'programmes' array and retrieve for each one the related items in the data source list. For that, I used oData filtering.

I iterated over each item for the current programme to retrieve photo of the responsible person and build an object for each team member.

If the current object was not appended to the 'responsibles' array (it does not contain the object), I append it.

After that I iterated over each item for the current programme again. It is not necessary, such structure I got after testing different parts of the flow. You can add the steps below to the same 'Apply to each' control that was used for building the 'responsibles' array. So, first, I added a new property 'currentMonth' to the current item retrieved from the list using this Power Automate expression:

addProperty(item(), 'currentMonth', items('Apply_to_each_(items)')?[formatDateTime(utcNow(), 'MMM', 'en-US')])

item() refers to the current item in the 'Apply to each' control. 'currentMonth' is the name of the property added. It should match to the last part of the accordant token in the template table. Now the most complex part. All month columns in the data source list should be named in the US format using three letters. You can follow another pattern but my example is for that case. Expression formatDateTime(utcNow(), 'MMM', 'en-US') returns the name of the current month in the described format. Now, it returns 'Jul'. Thus, expression items('Apply_to_each_(items)')?[formatDateTime(utcNow(), 'MMM', 'en-US')] refers to the value in the 'Jul' column for the current item in the 'Apply to each' control. The entire expression addProperty(...) adds property named 'currentMonth' and assigns to it the value contained in the 'Jul' column. In the next month, it will take the value from the 'Aug' column if you have such.

Then I added property 'previousMonth' using the same logic. But instead of the utcNow() returning the current timestamp, I used getPastTime(). Also, I added the property to the outputs of the previous step.

addProperty(outputs('Compose_(current_month)'), 'previousMonth', items('Apply_to_each_(items)')?[formatDateTime(getPastTime(1, 'Month'), 'MMM', 'en-US')])

The result is appended to the 'items' array.

Once the arrays containing team members and table items are ready, I compose an object for the current programme and append it to the 'data' array. There, I include the mentioned arrays and the name of the programme.

Before moving to the next programme, it is necessary to empty the 'items' and 'responsibles' arrays.

Finally, I start the Plumsail process.

The result file is attached.

test-pptx(1).pptx (169.4 KB)

1 Like

Hi Evgeniy,

This is amazing - thanks so much!

I can't quite get it working correctly, I think because my SharePoint list actually has many more columns than the 5 or so I need for the output "items". Do I need to do something in here to only select the fields that I want? (maybe add in a Select data operation or Append to array)?

Thanks again,

Phil

Hello Phil! To understand what is wrong, it is necessary to unfold each step in the flow run and research raw inputs and outputs to find out where it went wrong. The 'Apply to each' control iterates over items returned by the SharePoint action, not over columns. The more columns you have, the more properties each item has in its JSON object.

If you need further help with the flow, please share raw inputs and outputs of each step and the screenshots of your flow configuration. Also, describe what exactly went wrong. To avoid exposing essential data, you can clone your production list and fill it with dummy values. Then run the flow on it to use the latter in the flow and include them into the raw inputs and outputs you share.

Hi Evgeniy,

When looking at the code as you illustrated I realised some of the internal column names were different that what I thought they were. It is working now!

best regards,

Phil

Thank you for the update, Phil!