Chapter 4: Intro to the Logic Canvas

Chapter 4: Intro to the Logic Canvas

The Logic Canvas

The Logic Canvas is the screen where developers can create and edit the back-end processes that handle all the processing of data. The Logic Canvas uses services represented as steps in a flowchart to send information to places such as a page or an email.

View Model

From the View Canvas, in the left panel, there is a tab at the bottom labeled “Model, Controllers, & Events”. Open the View Canvas for the HelloWorld Webpage created in the previous chapter and click on this tab.

The menu will show the Model, Controllers, and Events. Currently there are no Controllers or Events, so it will only show the Model like the below.

Click on the gear button to open the Model in a new tab. The model is editable within the Logic Canvas. Once the new tab opens, it will look like the below screen.

The Logic Canvas

  1. Tabs: This area allows you to switch between the development area and the logs from Run Time
  2. Toolbox: Tools used to work with the Logic. Most commonly, you will search for services here to drag onto the Logic Canvas working area
  3. Toolbar: The icons at the top give the user control over the selected services within the Logic Canvas Working Area
  4. Logic Canvas Working Area: Development Area. Allows you to drag services from the Toolbox to create steps in the flowchart that manipulate the data that will be represented on the page.
  5. Menu: The icons at the top give the user control over the object as a whole or directs the user to pages within the IDE
  6. Live Chat: If you have a question, you can start a live chat for help with EASYProcess

From the Toolbox, make sure the “Services” tab is selected at the bottom left. Search for “Create Service Node”, which will be under the “Node Services” workshop, and drag in the service to the Logic Canvas Working Area.

The CreateServiceNode service will be where we place the data that will show on the page. Since it will act as something visible to the page, it is considered an output and we will need to flag it as an output in the service properties. To do this, check the “Expose Service Output” checkbox and a dot will appear on the service to note this has the property turned on.

Now the page will be able to access the data within the service.

Next we want to add data to the service. Double click the CreateServiceNode service to open it.

The Service Canvas

  1. Service Tab: A tab has been added for the service you have opened
  2. The Toolbox Bar: The left panel has changed to show information that will be useful for configuring the service
  3. Service Structure: The middle panel displays the service structure and the parameters it accepts. Each section within this panel can be clicked on to enter data and configure the service
  4. XML Viewer/Editor: The right panel allows the user to view the XML of the service. If you click into a single node of the service parameters in the middle panel, this section becomes editable and is the area where you will enter the data.

Click the “+” Button to add a Result to the Create Service Node service and set the Name and Value like the below.

Name: HelloWorld

Value: Hello World!

The Name becomes a node in the XML, so it cannot start with a number or contain spaces so that it remains valid XML. The value is the data that will be contained in the XML node, so this can be in a readable format.

Working with Dates

Next, return to the canvas and search for another service called “CurrentDate”.

Name it “CurrentDate”. For this example, the names of the services are very simple, but in future projects, it is a good idea to name your services after their function, so others (or even your future self) can look at it and understand what the logic is doing without opening each service.

In the service properties expose the service output, and connect it right after the CreateServiceNode.

Double click the service to open it.

This service can be used to return multiple dates.

Notice it has a Time Zone parameter. When working with dates, it is important to think about and specify the format and time zone of the date. If your application only supports one of each, it might still be a good idea to use conversion services so that when the application’s use grows to support multiple, it will save you development time in the future.

Click the “+” button three times to add three dates. When clicked into a TimeZone or Format parameter of the service, the Left Panel will have recommended values for each. These will give you an idea of the format the parameters accept.

Configure the service like the below.

  • Date #1
  • Name: SystemCurrentDate
  • Format:
  • TimeZone:
  • Date #2
  • Name: EasternCurrentDate
  • Format:
  • TimeZone:EasternStandardTime
  • Date #3
  • Name: CentralCurrentDate
  • Format:
  • TimeZone: CentralStandardTime

Testing the Service/Run in Step

It is a good idea to test your work as you go. After you configure each service, if you want to test just that service, you can run it from the canvas.

The buttons above the service in the middle panel are used to run the service from the Service Canvas. These buttons are also available from the Logic Canvas and will run the service you have selected.

Find the “Run in Step” button and click it.

Your results may be different, because of the location of your tenant. In this example, the system date time is the same as the Central date time. This is correct because the system is set up to be in the central time zone.

<SystemCurrentDate>11/6/2022 1:35:06 PM</SystemCurrentDate>

<EasternCurrentDate>11/6/2022 2:35:06 PM</EasternCurrentDate>

<CentralCurrentDate>11/6/2022 1:35:06 PM</CentralCurrentDate>

Formatting Output

Now that we have our dates, we need to think about how it will display on the page. We have exposed this service for output, but that will only allow us to reference the exact values as we see them from above.

It would take additional steps if we wanted the output to be formatted in a more readable way like the below.

System Current Date: 11/6/2022 1:35:06 PM

Eastern Current Date: 11/6/2022 2:35:06 PM

Central Current Date: 11/6/2022 1:35:06 PM

To do this, we can make use of the existing CreateServiceNode. Return to the canvas and rearrange the services so the order is:

  1. Start
  2. CurrentDate
  3. CreateServiceNode

Next, to make the development easier, click on the “CurrentDate” and click “Run in Step”. This will populate some logs of it running in the Output tab on the left panel.

Open the CreateServiceNode and click the “+” to add a new Result and set Name to “DateOutput”. In the value, use the Output you created by running in step and drag the nodes from the left to the right to create the reference to the previous service.

When you click on a node from the left panel in Output or in the Assistant working with recommended values, buttons appear on the bottom of the screen.

These can be clicked to select a different form from the selected node. If you drag it in, it will default to the “Select” option which is an xsl:value-of select=”...

Now run the CreateServiceNode in step and confirm the output looks as expected.

<HelloWorld>Hello World!</HelloWorld>

<DateOutput>

        System Current Date: 11/6/2022 1:44:19 PM

        Eastern Current Date: 11/6/2022 2:44:19 PM

        Central Current Date: 11/6/2022 1:44:19 PM

</DateOutput>

Working with Database Services

Return to the Logic Canvas and search for another service: Inquire. This will be within the “Database Services” workshop. Name the service “Inquire”.

Turn “Expose Service Output” on again from the Properties when Inquire is selected. Connect the Inquire to the Terminate to signify the end of the process flow.

Double click the service to open the Service Canvas.

The Inquire has many more parameters than the CreateServiceNode. There are both optional and required inputs. The required ones are denoted by the red asterisk *.

Connection Instance and Table Name

All the Database Services will require a Connection Instance and Table Name. The Connection Instance narrows the options the user is given for the table path in a later step.

Ultimately, the Inquire parameters will be used to create a SQL query with the following form:

SELECT   [Results]

FROM   [Table Path].[Table Name]

WHERE [Where Clause]

[Order By Clause] [Group By Clause]

When clicking into the Connection Instance, the left panel will have some recommended values under the “Static Values” node. Double click or drag in the “Application” value.

Next we will configure the Table Name. Database services have a helpful tool to do this called the Query Builder which helps the developer visualize the query that is being built by the user selections. Click the “QB” button next to TableName to open the Query Builder screen.

  1. Query Builder Tab: A tab has been added for the Query Builder you have opened
  2. Table Path: The table paths shown in the drop down are options based on the connection instance that was selected
  3. Table: The table list changes based on the Table Path selected. The list is searchable. When a table is found, it can be double clicked or dragged over to the working area to add it to the query.
  4. Query Builder Working Area: The middle area shows the tables that are selected. If multiple tables are selected, columns from one table can be dragged to columns of another table to create joins.
  5. Query Viewer Area: As the tables are manipulated, the Query Viewer Area is building the actual SQL query that runs.

Configure the Query Builder page to match the screenshot and click “Save & Close”

Table Path: Security_Base

Table: EPUsers

Where Clause

Next, we will configure the Where Clause. A tool is available for the developer to drag blocks, conditions, and filters to create the correct SQL syntax needed for the Where Clause.

As these are dragged down from the top, to the middle area, the bottom panel is building the actual SQL syntax Where Clause that is being built.

Drag down a Filter and select the “Column” tab in the bottom panel. Under the Static Values in the far left panel, “Columns in Table” will be dynamically populated. Drag in “UserId”.

In the “Value” tab, type in your UserId that you log in with to the IDE.

Results

Next we will add the Results. These are used to form the select clause of the Query. Click the “+” button under the results in the middle panel and it will add “Result #1”.

The Column and Expression of the Result are used to form a single column in the SELECT clause of the query.

SELECT   [Expression] AS [Column]

Again, once you click into the Expression or Column, the left panel Static Values is given a “Columns in Table” option as a recommended value.

Set up the Result as shown below.

Column: Name

Expr: CONCAT(FirstName, ‘ ‘, LastName)

Our result will be creating a new column which is the contact first and last name under the alias “Name”.

Testing the Query/Run in Step

Now that the query is fully configured, we can test it for proper syntax. It is a good idea to do this when configuring a Database Service to make sure the query is running as you expect.

The buttons above the service in the middle panel are used to run the service from the Service Canvas. These buttons are also available from the Logic Canvas and will run the service you have selected.

Find the “Run in Step” button and click it.

The left panel will change to the “Output” tab and will be populated with the logs of running the Inquire. Notice the Name field is returned.

Expand the nodes to get a better look at the format of the service when it returns.

Here is the full XML returned from the service. You can see the query that was used under the “Info” node.

<Inquire Output="True">

        <Output>

                <Result SelectOutput="True">

                        <Name>115                                                                                                  admin</Name>

                </Result>

        </Output>

        <Log>

                <Result jsonArray="true">

                        <TotalDuration>15.611</TotalDuration>

                        <RunIndex>1</RunIndex>

                        <TotalSize>658</TotalSize>

                        <StartTime>2022-11-06 01:21:28.4190258</StartTime>

                        <EndTime>2022-11-06 01:21:28.4346368</EndTime>

                        <Duration>15.611</Duration>

                        <XslDuration>0</XslDuration>

                        <Size>658</Size>

                </Result>

        </Log>

        <Columns>

                <Result jsonArray="true">

                        <ColumnName>Name</ColumnName>

                </Result>

        </Columns>

        <Info>

                <Result jsonArray="true">

                        <Query>select  CONCAT(FirstName,' ', LastName) as Name from EP_Platform5_DV.PaulJohnson_Security_Base.EPUsers WHERE  UserId = 'Tenant_Admin'  </Query>

                        <SortQuery>select  CONCAT(FirstName,' ', LastName) as Name from EP_Platform5_DV.PaulJohnson_Security_Base.EPUsers WHERE  UserId = 'Tenant_Admin'   [OrderByPlaceHolder] </SortQuery>

                        <ParameterizedQuery>select  CONCAT(FirstName,' ', LastName) as Name from EP_Platform5_DV.PaulJohnson_Security_Base.EPUsers WHERE  UserId = @Name0  </ParameterizedQuery>

                        <NoOfRecords>1</NoOfRecords>

                        <EOF>True</EOF>

                        <FetchedRow>1</FetchedRow>

                        <ConnectionInstance>Application</ConnectionInstance>

                        <ReturnTotalCount>True</ReturnTotalCount>

                        <RowCount>50</RowCount>

                        <NoOfRecordsRequested>50</NoOfRecordsRequested>

                        <NextStartIndex>0</NextStartIndex>

                        <Parameters>

                                <Parameter>

                                        <Name>Name0</Name>

                                        <DataType>AnsiString</DataType>

                                        <Value>Tenant_Admin</Value>

                                        <ColumnName>UserId</ColumnName>

                                </Parameter>

                        </Parameters>

                </Result>

        </Info>

</Inquire>

Running the service revealed that there is lots of white space after the name, so it is not showing as a readable name the way we intended. To fix that, go back into the Result and add an RTRIM function

CONCAT(RTRIM(FirstName),' ', RTRIM(LastName))

Run the service again and it will show your user’s First and Last name separated by a single space

Working with User Session Variables

Previously you were querying the database for information about your own user. It is still good to know how to query the database for user information, but there is an easier method to get current information about your own user.

On login, all the information from your user in the database is put into user session variables so it is easier to reference. The simplest application of using this is to tell if the user is logged in. If the system is checking a user session variable for UserId and it is blank, then it means the user is not logged in. This is a good approach because user’s get logged out when the session expires and with it, the user session variables are also removed.

Go to the CreateServiceNode and click the “+” to add a new Result called “Name”. For its Value, look in the left panel under the “User” tab. These are the user session variables.

Drag in the FirstName and LastName to the Value. This is not quite ready yet, but it has the references we need from the user session.

Next we will have to concat the 2 strings together, like we previously did with the SQL CONCAT function.

Go to the “Functions” tab in the bottom left of the screen. Here you can find functions to use with the XSL strings once the data is in EASYProcess.

To achieve the desired “[FirstName] [LastName]” format, we can approach it one of two ways

  1. Have 3 XSL value-of variables. One for FirstName, one for the space, one for the last name.
  2. Have 1 XSL value-of variable with a concat function

Testing/Run in Step

As previously mentioned, it is always a good idea to test as you develop each piece. However, if you tried to run this in step, it would be running as the system and not a user, so no user session variables would exist. This makes it difficult to test outside of the finished page.

When you run into cases where you depend on the final application page load to perform testing, it becomes very important that you also confirm the output is as expected in the logs.

We will come back to this when it is set up to work with the page.