Table of Contents

Creating a UI view method

What are UI view methods ?

UI view methods are methods which can be executed on client side.

Like C# methods they can have parameters and a return value. Their execution can be synchronous or asynchronous.

How to create a UI view method

When editing a UI view, you can modify or create methods by clicking on the Methods tab.

You can then see a list of existing methods for the edited UI view, and you can create a new one by clicking on the + button of the toolbar.

Asynchronous

When this parameter is set to true, the method will be defined like an async C# method. It allows among other things to use the await keyword to wait for a task to complete before executing the next code statement.

Otherwise, the method will be a standard synchronous methods.

DotNet return type

This is the C# type returned by the method. If the value is empty, the method will act like a void C# method.
When editing some code and using the method, this is the type which will be used for intellisense.

Name

This is the name of the method which will be used in the UI view template or the code of an action / rule / method.

Description

This optional parameter is the short description of what the method will be used for. It will be displayed by the code editor intellisense.

Module name

This is the module to which the method will be associated. By default this is the same module as the UI view.

Documentation

This optional parameter is the complementary documentation for the method. It will be displayed by the code editor intellisense.

Parameters

These are the parameters which can be passed when calling the method.

Example : MyMethod(param0, param1, param2)

Position

This is the position of the parameter in the method definition.

DotNet data type

This is the C# type of the parameter. It will be displayed by the code editor intellisense.

Name

This is the name of the parameter which will be used in the method.

Description

This optional parameter is the short description of what the parameter will be used for. It will be displayed by the code editor intellisense.

Module name

This is the module to which the method parameter will be associated. By default this is the same module as the method.

Code

This is the code which will be executed when calling the method. It is written in C#.

How to use UI view methods

UI view template (Method button)

A method can be referenced by a method button in the template, see this article

UI view code (actions, event rules, methods)

All methods of a UI view can be accessed with the Methods.MyMethodName syntax :

List<string> customerNames = Methods.GetCustomerNames(categoryCode, subCategoryCode);

In this example, we call a method GetCustomerNames which take two parameters (categoryCode and subCategoryCode) an return a list of string.