Parsware
All articles

For Power Apps

Screens that read Dataverse rows

A drawn screen can load real Dataverse rows when it opens, count them, chart them and list them. Here, a panel on the Case form shows how many cases there are at each priority and the five newest ones, read live as the signed-in user.

A case record with a drawn panel headed Cases at a glance: a bar chart of cases by priority, High, Normal and Low, and a list of the five newest cases with their priorities, next to the title "Screens that read Dataverse rows"

The screens in the last three articles worked with the record they sat on. A screen can also go and read rows of its own: every case at a priority, the newest five, anything you can ask a table for. It reads them when it opens, as the person looking at it, so it only ever sees what Dataverse already lets them see.

We'll add a Cases at a glance panel to the Case form, with a bar chart of how many cases there are at each priority and a list of the five newest cases.

1. Draw the screen

Make a new design as in A drawn screen on a form: Designs › New, name it Case overview, Kind App, then open it in the Designer. Draw a frame 760 × 300, and on its Screen tab set This object is to The screen. Name the frame Overview.

Inside it, draw a heading, two small captions (Cases by priority and Newest cases), and leave room for a chart on the left and a list on the right.

2. Give the screen somewhere to keep the rows

Select the Overview frame. On its Screen tab, under Screen state, press Add a state field for each of these:

Name Starting value Holds
high, normal, low 0 how many cases there are at each priority
probe [] a page of rows nobody reads (see below)
latest [] the five newest cases

3. Load them when the screen opens

With the frame still selected, press </> and choose Screen opens. Write four lines:

loadRecords("par_case", "probe", { top: 1, where: { par_priority: 100000003 }, countInto: "high" });
loadRecords("par_case", "probe", { top: 1, where: { par_priority: 100000002 }, countInto: "normal" });
loadRecords("par_case", "probe", { top: 1, where: { par_priority: 100000001 }, countInto: "low" });
loadRecords("par_case", "latest", { top: 5, orderBy: "createdon", descending: true });

The code page for Screen opens: the five state fields high, normal, low, probe and latest on the left, and four loadRecords lines in the editor, three counting cases at each priority into high, normal and low, and one loading the five newest cases into latest

loadRecords takes the table's logical name, the state field to put the rows in, and what to ask for. As you type the first argument the editor offers the environment's tables by name.

  • where keeps only the rows whose columns match. A choice column is matched by its number; ours are 100000001 (Low), 100000002 (Normal) and 100000003 (High).
  • countInto puts the number of all matching rows in a state field, not just the ones that came back. That's why the first three ask for top: 1 and drop the row into probe: we only want the count, and Dataverse counts as it answers, so it costs nothing extra.
  • orderBy and descending sort the rows, and top says how many to fetch.

4. The chart

Drag Chart from Components onto the left of the screen, 340 × 196. Its Screen tab sets the kind of chart: we left it on Bars.

What it draws is its Value: a list of labels and numbers. Press </>, choose Value, and build it from the three counts:

[
  { label: "High", value: state.high },
  { label: "Normal", value: state.normal },
  { label: "Low", value: state.low }
]

The code page for the chart's Value binding: a list of three items, High with state.high, Normal with state.normal and Low with state.low

Then choose Shown and write state.high + state.normal + state.low > 0, so the chart appears once the counts have arrived rather than drawing three empty bars first:

The code page for the chart's Shown binding: state.high + state.normal + state.low > 0

You draw where the chart goes and how big it is. The chart works out its own axis, its ticks and its labels each time it draws, so it copes with numbers you didn't plan for.

5. The list: draw one row, get one per record

On the right, draw a frame for the list, 344 × 196. On its Screen tab, make it A list, and on its Graphic tab turn on Auto layout › Vertical, so the rows stack.

Inside it, draw one row: a frame 344 × 39 with two texts in it. Then:

  1. Select the row, make it A list item, and set One of these per to state.latest. That's the whole of the repeat: one row is drawn for every case in latest.
  2. Bind the first text's Text to row.par_name and the second's to row.par_priority. row is the case that copy of the row is showing.

The designer with the Case overview screen: Cases at a glance, the two captions, and the list on the right with its one drawn Case row selected, showing Case name and High; on the right the Screen tab says This object is A list item, and One of these per holds state.latest

row.par_priority reads High, not 100000003. A choice, a lookup or a status column comes back with its label, because that's what a screen shows people.

Save, then Publish into your solution.

6. Put it on the form

As before, the component needs a column to sit on: we added a text column Overview to the Case table, in the same solution. In the form designer, add it where the panel should go, tick Hide label, add the Parsware Runtime component and type Case overview as the static Design:

The Add Parsware Runtime panel: Value bound to the Overview column, the other columns empty, and Design set to the static value Case overview

Press Done. The form designer runs the screen for real, so it already shows live counts and the newest cases:

The form designer with the Case form: below the Case checklist panel, the Cases at a glance panel shows a bar chart of High, Normal and Low and the five newest cases with their priorities

Save and publish, and open a case:

The case VPN drops every hour in the Parsware Samples app, with the Cases at a glance panel below the checklist: bars for High, Normal and Low between 60 and 70, and the five newest cases from Badge does not open the third floor to Shared drive is read-only

Good to know

  • It reads as the person looking at it. The screen asks Dataverse with the signed-in user's own session, so a row their security roles hide is a row the chart doesn't count and the list doesn't show. Parsware adds no permissions of its own.
  • It reads when the screen opens. Opening another case runs the queries again. To refresh without leaving, put the same lines in a button's Pressed.
  • The panel doesn't know which case it's on. These are queries over the whole table. A screen that works with the record's own values sits on its columns, as in A drawn field.
  • Lists can page. loadRecords also takes skip, so a list can show twenty at a time with Previous and Next, and contains filters rows by part of a column for a search box. The Starter app in the samples solution does both.

Next

Modals and drawers from a form: a screen on a form opening a card over the whole page. The whole series is in the reading list.