Parsware
All articles

Power Apps

One control, several columns

A drawn field can work with more than the column it sits on. Bind up to three more columns to the same Parsware Runtime component, and the screen reads them all and writes any of them by name. Here, choosing a contact channel also fills in the case's next step.

A case record whose Contact channel field shows Phone and, below it, Next step: Call back within one working day, with the ordinary Next step field further down showing the same sentence, next to the title "One control, several columns"

The drawn field from the last article reads and writes one column, the one it sits on. Often one choice should change more than one thing. Choose Phone as the contact channel, and the case's next step is to call back.

The Parsware Runtime component takes up to three more columns besides the one it sits on. A screen reads each of them and can write any of them, by name. We'll make the channel field set a Next step column as well.

1. Bind the second column

The Case table has a single line of text column Next step, ex_nextstep, in our solution. In the form designer, select the Contact channel field, open its Parsware Runtime component, and set Second column to Next step:

The Parsware Runtime properties in the form designer: Value bound to Contact channel, Second column set to Next step, Third and Fourth column empty, and Design set to Channel field

Each of the extra slots is a column picker, so the name can't be misspelled. We also put Next step on the form as an ordinary field, to watch it change. Save and publish the form.

2. Read it

Every bound column is available to the screen as fields.<logical name>, the column the screen sits on included. In the Channel field design, add a second text below the value, mark it A paragraph, and bind its Text to:

fields.ex_nextstep == "" ? "No next step yet" : "Next step: " + fields.ex_nextstep

3. Write both

Change each button's Pressed to write two columns. For Phone:

setFieldValue("Phone");
setFieldValue("ex_nextstep", "Call back within one working day");

With one argument, setFieldValue writes the column the screen sits on. With two, the first is the column's logical name and the second is the value. Email and Chat get their own sentences.

The code page for the Phone button with the two setFieldValue lines under Pressed

Save, Publish, and open a case.

4. Use it

Press Phone:

The case VPN drops every hour marked Unsaved. The drawn Contact channel field shows Phone and Next step: Call back within one working day, and the ordinary Next step field below shows Call back within one working day too

Both columns changed at once: the channel the field sits on, and Next step, which the ordinary field further down the form shows as well. Both are unsaved changes to the form, saved together when the record is saved. Open a case and type in the ordinary Next step field, and the drawn one follows, because it reads the same column.

The whole control, written out

With the second column bound, the design is:

Channel field (design, kind App)
└── Field (screen, 460 × 130)
      Value text      Text:     field.value == "" ? "Not set" : field.value
      Next step text  Text:     fields.ex_nextstep == "" ? "No next step yet" : "Next step: " + fields.ex_nextstep
      Phone           Pressed:  setFieldValue("Phone");
                                setFieldValue("ex_nextstep", "Call back within one working day");
      Email           Pressed:  setFieldValue("Email");
                                setFieldValue("ex_nextstep", "Reply by email today");
      Chat            Pressed:  setFieldValue("Chat");
                                setFieldValue("ex_nextstep", "Answer in the chat window");

field.value is the column the screen sits on; fields.<logical name> reaches any bound column, that one included.

Reading and writing, side by side

Want Write
The column the screen sits on field.value
Any bound column fields.ex_nextstep
Set the column the screen sits on setFieldValue("Phone");
Set another bound column setFieldValue("ex_nextstep", "…");
Clear a column setFieldValue("ex_nextstep", "");

The column slots on the component are what make a column reachable. A column that isn't bound reads as empty and can't be written, so the form designer's four slots are the control's whole reach into the record, which is also a fair summary of what it can't touch.

Uses for more than one column

  • A choice and a consequence, as here: a channel and the next step it implies.
  • A pair that belongs together, such as a start and an end date set by one This week button.

When a rule like these must hold however the record is saved, from an import or a flow too, put it on the table as well, in a business rule or a plug-in. The drawn control makes it easy on the form; the table makes it true everywhere.

Good to know

  • Up to four columns in all: the one the component sits on and three more.
  • A column that isn't bound reads as empty. fields.ex_somethingelse is "" rather than an error, so a screen drawn for one form still works on a form that binds fewer columns.
  • Bind every column a screen writes. setFieldValue("ex_other", "…") on a column nobody bound can't reach the form, so the screen reports it, naming the column and saying to bind it in the form designer.
  • The drawn field keeps following the form. After a button has written a column, typing a different value in the ordinary field still updates the drawn one straight away. (Before runtime 0.44 the drawn line kept the button's value until the record was opened again.)
  • The same types as before: text, numbers, currency, dates and yes/no. Lookups and choices can't be bound yet.

Next

Screens that read Dataverse rows: lists and charts on a screen, bound to real records. The whole series is in the reading list.