Report Designer

From Resco's Wiki
(Redirected from Mobile report)
Jump to: navigation, search

Report Designer is a tool available to CRM administrators that allows you to design custom document templates. The template is then saved in your CRM as a record and it can be used across all mobile projects in your organization.

If you don't want to use the designer, you can create or edit the report templates directly as XML files.

Tip This article introduces the concepts and basic functions of the Report Designer. To jump into action, check out also the Report Designer examples.

Mobile reports

Reports are read-only visual representations of entity data. Users of the mobile app can use the templates to create reports on the go, using data from CRM. Reports are generated directly in the Mobile CRM application, even in offline mode, so there is no need for any connection to the internet or CRM server. This allows you to create e.g. an invoice or a service report at the customer and save it to a CRM record as an attachment. Or instantly email it to your customers and partners. Or use a wireless printer to directly print it.

Documents can be generated in Word (.docx), Excel (.xlsx), PDF, or HTML formats. It is also possible to use one or more records as a source for the report.

Mobile reports support many popular building blocks, such as

  • Header and footer sections that repeat on all pages of the document
  • Repeating blocks for recurring items (such as invoiced products)
  • Any field from your entities
  • Images, both static (for example your company logo) and dynamic (for example a signature)
  • Dynamic reports involving business logic, for example, calculations, show or hide sections under specific conditions, etc.

See also the followings blogs: Blog

Accessing the designer

Report Designer can be started from the management console of your CRM:

  1. Using a web browser, log in to your CRM.
  2. Launch the designer:

In the case of Resco Inspections, you can start the Report Designer directly from the Questionnaire Designer: Click Mobile Report while editing a template; this button takes you directly to the report for this questionnaire.

Using the designer

On start, the Report Designer shows a list of existing reports. Use the toolbar in the top part of the screen to access most functions.

New
Create a new report. Specify a name, select an entity, the language, and decide if you want a report for a single record, for multiple records, or a combination.
Edit
Select an existing report and open it for editing.
Properties
Select a report and modify its properties.
Delete
Delete selected report.
Activate
Active reports are available in the app.
Deactivate
Inactive reports are not available in the app.
Import
Upload an XML file with a report.
Export
Download a copy of the select report template to your computer as a file in XML format.
Clone
Create a duplicate of the selected report template.

You can use the Search field above the toolbar to filter your reports. To sort the reports, click the header row of the report list.

Creating a report

Create report.png

Click New and provide the following details:

  • Enter a unique name for the report. The name is used to identify the report in the designer and also in the app.
  • Select an entity as the primary variable. The data of this entity can be used in the report. However, you can link other entities to add additional information to the report.
  • Select the language of your report. The app only displays reports that match the language of the app, and the universal language-neutral reports.
  • Select a source: decide if you want a report for a single record, for multiple records, or a combination. Again, this may impact if your report is displayed in the app, for example, single-record reports are not available when you use multi-selection in views.

Editing a report

A new report contains a header block, a footer block, and a grid block.

  • Use the toolbar buttons to add or remove grids, cells, columns, repeating blocks, and images / signature.
  • Left pane displays a list of fields of the selected entity. Drag fields to the report.
  • Use the right pane to modify the properties of selected items.

Once you've done editing a report, save changes and remember to activate it to make it available in the app.

Structure

Mobile reports are a collection of a few elements:

  • Text blocks and image blocks define the data to display.
  • The Grid element is used to arrange the blocks.
  • The Repeater element allows iterating over a collection of CRM records (contained in the primary variable or fetch variables).

Grid

Grid is the basic container element of a mobile report. It contains blocks of text and/or images arranged into a table pattern.

Click Add Grid to place a new grid. Grids can be added to the top level of your report, or into a Repeater element. New grids are added at the end of their parent element, use the buttons Up and Down to move them around.

Each grid starts with a single empty cell. Select the grid and click Add Column and Add Row to increase the number of columns and rows of your grid.

Grid in report designer.png

Column width

The maximum width of the grid is equal to the width of the page. You can specify the width of each column on the Properties pane in the Columns parameter, either a fixed width (in pixels) or flexible width (using stars notation). Separate values for each column with a semicolon.

If the grid contains at least one column with flexible width, the width of the grid is set to the page width. To calculate the width of flexible columns, we subtract all fixed-width columns from the page width and distribute the remainder evenly. To increase the width of a flexible column, add a number before the star; a 2* column is twice as wide as a 1* column.

In the example above, the first column is 100 pixels wide, and the remaining space is divided to column 2 and column 3, with column 3 being twice as wide as column 2.

Row height

The height of each row is specified in the Rows parameter on the Properties pane. Use Auto for automatic height calculation, or enter an explicit pixel size. Separate values for each row with a semicolon.

The automatic calculation uses the maximal height of the blocks in the grid row. That means either the height of text in a particular font or the height of an image (the image height might be scaled automatically to fit into a particular width).

In the example above, the first row is exactly 100 pixels tall, the remaining two rows use flexible height to match their content.

Parent grid

A parent grid essentially behaves just like a regular grid, with the additional function that you must select a related entity. All fields of the related entity become available in the entire report. This is similar to defining an additional fetch variable using the Edit Sources button, but you don't have to write the fetch.

Header and footer

Header and footer elements are essentially very similar to grids, with the following exceptions:

  • They repeat on each page of the report
  • They cannot be deleted from the report (but they can be empty)

Text block

The purpose of the text block is to display textual data. This can be either data from your organization or simply static text.

Click Add Cell to add a text block to your report. A text block can be placed into any grid, or into the header or footer.

You can configure the behavior of your text block on the Properties pane.

  • Column and Row define the position of the block in the grid (starting with 0, 0 for the top left corner).
  • Columns and Rows define the spanning of the block across multiple columns or rows. Default values: 1. The actual pixel size of a text block depends on the properties of the grid.
  • Style and Visible control if and how the text is displayed
  • Binding Type defines how the Binding should be interpreted:
    • Constant is used to display text verbatim, for example for labels.
    • Raw Value and Value are used to display dynamic data.

Dynamic data

Drag a field from the left pane directly to the text cell. This binding can be the name of a primitive (input) variable, such as dateRange. It can also be the name of a composite (primary, fetch) variable and a particular field, for example: order.totalamount.

In order to display multiple variables in a single field, wrap their names in curly brackets: {order.street1}, {order.city}, {order.country}. Any text outside of brackets will be copied verbatim (as a constant).

Formatting

If you need to format a numeric or date value in a certain way, add a colon and a formatting string after the variable name: {order.createdon:YYYY-MM-DD}. Please see the C# Visual Studio reference for the possible formats.

You can optionally include also the culture identifier to format dates or numbers for a specific culture. This controls the names of months, separators, etc.: {order.createdon:YYYY-MM-DD;en-US}. Examples:

  • To convert the decimal variable to currency, use this C# format in the binding field – {variableName:C}.
  • To convert DateTime variable to date variable, use this C# format in the binding field – {variableName:MMMM d yyyy}.

Image block

The purpose of image blocks is to display JPEG or PNG images. Their size and position follow the same rule as the text block. Click Add Image to add it into any grid, header, or footer.

Static images are loaded from the Offline HTML section. You need to specify the image path: folder/name.png or folder/name.jpg.

Dynamic images are loaded from note attachment or cloud documents. To select an image, you simply define a fetch filter for the note entity. Remember that you can use also other variables in place of filter condition values.

See also Report Designer examples.

Signatures

We offer multiple ways how to display signatures on your reports. Click Add Signature to add a signature block into your grid, header, or footer.

See Adding signatures to reports for more information.

Repeater

Thanks to the repeater element, you can display a list of multiple records in your reports. The element consists of an optional header grid element and a body. If the repeater spans multiple pages, the header is repeated on each page. The body of the repeater may contain a single or multiple grid elements. You can also nest one or several repeater elements into the report.

The repeater inherits all variables defined for the report, this means, all fields available on the parent level are also available for the child. It also contains one special iteration fetch variable. The repeater body is rendered for every record from this query. This example uses a repeater to list all contacts related to an account.

Child repeater

A child repeater essentially behaves just like a repeater, with the additional function that you must select a related entity from a list when creating the repeater. This saves you the hassle of defining the fetch variable using the Edit Sources button.

Visibility

By default, blocks that you add to your report are visible, unless they are empty. For example, if you add "City" to your report but the record does not have city defined, no city is displayed. In fact, if "City" is the only field on a report row, the entire row is skipped (unless you define a fixed row height, see above).

You can control the visibility of a text block, image block, or grid, by setting the Visible property on the Properties pane. The value used must be a valid variable in curly braces, e.g. {customer.primarycontactid}. The block or grid is hidden when the variable is false, zero (0), or null (empty). If you need the opposite behavior, use the exclamation mark before the variable: !{customer.primarycontactid}.

To see this in action, see the cell visibility example.

An advanced tip that uses visibility: You can add multiple blocks to a single cell. Normally, these would simply overlap, for example, you could see two texts superimposed in the same space. However, you can use conditional visibility to display only the appropriate text block.

Page breaks

To keep your report organized, you can force a page break before a block, if at least one line of the block does not fit on the current page. Select a block in the designer and check Break on the Properties pane. This block will start on a new page of the report.

Editing styles

Click Edit Styles while editing a report template to customize cell styles. Unlike styles in Woodford where the styles are shared across an entire app project, styles in the Report Designer are unique per report.

See Style editor for more information.

Edit sources

Mobile reports contain text, numbers, and images. This data can be static or loaded from the database. When you're creating a report, you must decide about the primary variable of your report: either a single record or a collection of records. However, sometimes you might need additional variables in your report.

Click Edit Sources to define the additional variables:

  • Primitive variables: string, decimal number, boolean, date and time
  • Complex variables: fetch result, fetch table, fetch table lookup

Once defined, the variables are listed in the left pane, along with primary variables. Drag them to the report as needed.

Variables can be defined on the root level or repeater level. Root variables can be used in the entire report; variables defined on the repeater level are only available for use in that repeater.

Primitive variables

The simplest use case is reuse. For example, if you need to use the same static text or number on several locations of your report, you can define an appropriate variable and add it to the report multiple times as needed. If you later need to update this value, you simply change it once in the variable definition.

Variables can be used to perform arithmetic or string operations. See an example how to use variables to multiply data and display them in your report.

For a repeater block, you can use variables, for example, to number the individual instances of the repeater. See automatic numbering for inspiration.

Complex variables

Complex variables involve FetchXML to retrieve additional data for your report. Often, you need to display data from a related entity; for example, on an Account report, you might want to display related contacts.

You have to define a data filter to get the records that you need. In the filters, you can use other variables in place of filter condition values.

Another aspect of complex variables is that they are not a single value, but often an array of multiple values. We use the dot notation to access the values, for example, myContact.name.

In some cases, adding a parent grid to your report can serve as a simpler alternative to defining a fetch variable using the Edit Sources button.

Fetch variable

This variable represents a single record loaded via fetch. If the fetch returns more than one record, the rest is discarded.

  • Click Edit to specify fetch conditions.
  • To use other previously defined variables as parameters in the condition, use the Set Variable button.
  • If you need the last or first record, use the Sort button.

By default, all attributes are returned. To access the entity attributes, use the dot notation (as can be seen in the Fields pane on the left).

Use fetch variables if you need to show attributes of a related record on the report, or the record is needed for a calculation.

Fetch Table variable

This variable represents a lookup table, i.e., a key-value pair.

  • Values are the records returned by the fetch query.
  • The key is the value of entity property defined as the LookupKey. In general, you would use the logical id, name, or a group-by alias.

When to use: This feature is an optimization, it allows to load multiple records in one query execution. Then each record can be accessed via the Fetch Table Lookup variable.

The Aggregates button allows defining aggregation and grouping attributes for a Fetch Table variable. If aggregate or group by attributes are set, only these are returned (not all attributes). Please note that alias is mandatory and you might want to use it for the Fetch Table key.

Fetch Table Lookup variable

This variable retrieves a record loaded into a Fetch Table. It has two parameters:

  • Table name: this is the name of a previously defined Fetch Table variable.
  • Index name: this binding defines the value of the key for the lookup. This can be static text, or use curly braces for a value lookup.

Built-in variables

Report Designer also comes with a few built-in variables, predefined for your convenience.

  • The PageNumber variable (Page: {PageNumber}) specifies the sequence order of each page.
  • The PageCount defines the total number of pages that the report contains.
  • The CurrentDate variable ({CurrentDate:DDDD}) enables you to add the date and exact time when the mobile report was generated.
  • The RowIndex variable applies to repeaters and contains the row number. To use it, add {<entity>Index} to a field; for example, {contactIndex} if you're in a repeater that lists contacts.

For example, in the footer (or elsewhere on the page) you could include {PageNumber}/{PageCount}, dynamically changing depending on the page the user is viewing at that moment.

Input variables

Sometimes, you want to allow users that they specify a certain parameter at run time, for example, a date range of the report.

  1. Select the report body and click Edit Sources.
  2. Add a variable and check Visible to make it visible as an input parameter when generating the report.

Fromtoparameter.png

Add business logic

Just like many other content tools available on the Resco platform, Report Designer also supports rules that can add some business logic to your reports. In the case of the Report Designer, whenever a new report is created, or a new instance of a repeating block is created, this triggers an On Create event. You can define steps that should be performed when such an event happens. For reports, the steps don't allow you to control the user interface (enable or disable a field, show or hide something, etc.); you can only assign values to variables or perform arithmetic operations. (Variables can be used to hide a portion of the report indirectly; see Visibility.)

To define the steps, proceed as follows:

  1. Select either the report body or a repeater.
  2. Click Edit Sources to display a list of variables defined for that component.
  3. Select any variable and click On Create to display the rules editor.
  4. Use the usual Rules editor syntax to define one or more steps that should be performed.
  5. Remember to save all changes.

Tips:

  • On Create is not available for "Fetch" type variables. Fetches query data from the database, it does not make sense to define On Create steps for those.
  • To keep things organized, the steps are defined per variable. However, all steps defined for variables on the same level of hierarchy run together, in a sequence.
  • Steps are executed in the same order as the order of the variables in the list. You can use the Up and Down buttons to change the order of variables.
  • If you first define var1, then in the steps of var2 you can utilize var1. However, using var2 in the steps of var1 would not be possible.
  • Often, it makes sense to initialize variables on the parent level and then perform additional operations on the child level.

Report Designer examples include several use cases where you can see the On Create rule in action.

Running the reports

You can run the reports in the app, in various components:

  • On a form, a report can be configured via Form commands. Users can access the report using the hamburger menu in the top right corner of the form.
  • On a view, a report can be configured using the Multi Select function. Users can select multiple records and then select the action from the bottom right corner.
  • On a questionnaire, a report can be configured using the Mobile Report button in the Questionnaire Designer, or using Commands. Users can launch the report for completed questionnaires. It is also possible to configure an automatic generation of reports on completion, or allow users to manually run a preliminary report for an in-progress questionnaire.

JavaScript

Resco JavaScript Bridge can be used to extend the no-code functionality of mobile reports. For example:

  • Show or hide a (custom) command related to reports.
  • Define the behavior of a custom command related to reports.
  • Automatically run a report in certain conditions.
  • Perform an additional action (e.g., create an email message).
  • Modify report's XML source. You can even skip Report Designer, define the entire report in JavaScript code, and then run it.

Technical information

Behind the scenes, the definitions of mobile reports are stored in a custom entity called "resco_mobilereport". The actual structure is saved in the field Body (resco_data) in XML format.