Jump to content

Row script

From Resco's Wiki
Warning Work in progress! We are in the process of updating the information on this page. Subject to change.

You can define multiple row designs for a view, and then you can define conditions when a specific row design should be used. Additionally, you can create a custom variable and define a custom field on the view. Row script rules are evaluated for each row during either loading or refreshing of the view.

Note Please check this blog post for an additional example of row script use. Blog

Multiple views example

In the following example, we will create a second row with a red background, this will be used when the field Name does not contain data.

Create a new style with red background

  1. Click Edit Styles to display the Style editor.
  2. Select primary from the style list, and then click Add. This creates a clone of the primary style.
  3. Change the BackColor (background), ForeColor (text color), and rename the style (for example Red Primary).
  4. Click Save & Close to close the styles editor and return to the view designer.

Create a second row

You have multiple options for creating rows:

  • Click Clone Row to create a copy of the row selected in the Properties pane. Then rename the row, for example to RedRow.
  • Click Add Row to create an empty row, where you can add fields and design it from scratch.
  • You can also click Copy Design to copy the design of any view from any entity.

In the new row, select a cell and change the style from Primary to Red Primary.

Create a row script

To define when and how the different the row designs are used, you need to set up a row script. Row script is a combination of steps and conditions (what should happen and when).

  1. Click Row Script to open the script editor.
  2. Add the following conditions and steps.
    If entity.name does not contain data
    Then Step TemplateIndex Assign RedRow
    Else Step TemplateIndex Assign Default
  3. Click Save & Close.
Warning Do not use LoadFetch, LoadReference, and NewInstance in row scripts, even if Woodford allows you to configure them. These asynchronous operations do not work in this context and can cause problems.

Custom field on the view

In this example, we create a custom field which we add to the row on the Order view. We create a new string variable where we add following string: {Entity.customerid}: {Entity.name}.

Custom field on the view step 1

Next, we add this variable to our row.

Custom field on the view step 2

This is how it looks in the application.

Custom field on the view step 3

Custom label for Calendar activities

The calendar is divided into four views: Agenda, Day, Week, and Month. While the Agenda view displays all fields from the selected entity view, the other calendar views show only the information from the first field with Primary style. In this example, we create a custom field to display multiple fields in the rest of the Calendar views.

Start by creating a new view either for Activity or any activity entity type.

Custom label for Calendar activities: New view step 1

In the View editor, Click the Row script in the topbar panel. Create a new string variable by choosing the “Format Text” option from the available actions. In the text field, type what you want to see on the label.

  • For entity records, use curly brackets and insert field logical (not Display) name, e.g. {Entity.name} or {Entity.regardingobjectid}.
  • For new lines, use \n.
  • For additional text that's not part of the data; just type into a string.

String used in this example: {Entity.name}\nRegarding: {Entity.regardingobjectid}\n{Entity.scheduledstart}
Custom label for Calendar activities: Custom field string in Row Script step 2

Save the Row script and add the custom field into your view.
As mentioned in the beginning, Calendar (other than the Agenda view) shows only the information from the first field with the Primary style. Therefore, make sure that the custom field has the style set to Primary.

Custom label for Calendar activities: add custom field into view and check style step 3

Change style on view dynamically

Since version 10.1, there is also a different option in changing the field style on view dynamically, based on its value or other conditions instead of creating a different row design. It is also possible to change the field’s style by using Row Script directly.

To learn more about this approach, please check this part of WEBINAR and HERE to see the setup and see it in action. Webinar




{{#CI form: title = Was this information helpful? How can we improve? | type = inputs | [textarea] }}