Using the Generic HTML Function

The Generic HTML Eval Script With Result function enables you to run a script for a document (by URL and/or Title mask), without adding screen elements to the project.

This function uses the Generic HTML connector, and works with Chrome and Firefox. The connector must be enabled in the browser (see Connecting to Chrome Using the Generic HTML Connector).

Only one browser should be open when this function is executed. More than one tab can be open.

This section illustrates how to build a sample Generic HTML function. You can download the sample project from here.

When this project runs, you can copy the sample text from the callout, for example, a sample script alert("Hello World") and a sample website URL https://www.wellsfargo.com/, paste the text into the relevant parameters, and then click to run the Generic HTML function to execute the script.

Workflow:

Step 1: View the Generic HTML Function

Step 2: Create the Business Entities for the Function

Step 3: Create a Callout

Step 4: Create an Event Handler

Step 5: View the Results

Step 1: View the Generic HTML Function

You can view the Generic HTML function in the Library References.

1. To access the function, open the Direct.GenericHtml.Library under Project > References > Library References.
2. Click the Functionality tab, and in the Functions and Events area, expand the Eval Script with Result function.

Step 2: Create the Business Entities for the Function

Create a new user instance of type Text to use as the return value of the assignment. Add a new user type that contains three text properties and the required function. Create an instance of the new user type.

1. In Business Entities > Instances, create a New Instance of type Text, and name it Text Result.

2. In Business Entities > Types, create a New Type and name it Generic HTML Functions.

3. Create a New Property of type Text and name it Script. Similarly, create Title and URL properties.

4. Add a New Function and name it Eval Script with Result.
5. Select Insert Instruction > Assignment.

6. Click Select Object, and select Business Entities > Text Result.
7. Click Enter Value and select Library Objects > Generic HTML Functions and then select Eval Script with Result.

8. Click Select Script and select Script. Similarly add the Title and URL.

9. Right-click Generic HTML Functions and select Create an instance of 'Generic HTML Functions'.
10. Save your project.

Step 3: Create a Callout

Create a callout that includes an action link to call the Eval Scrip with Result function, and three input text boxes that enable you to enter the Script, URL, and Title parameters in runtime. The additional text in the callout is provided as sample data that you can copy to test the examples.

1. In Presentation > Callouts, create a New Blank Callout and name it Generic HTML Functions.
2. In Links & Data, click Insert an action and select Insert Instruction > Function Invocation, and then click Select Function and select Business Entities > Generic HTML Functions > Eval Script with Results.
3. Update the text to Eval Script with Result.

4. Press Enter and type Parameters. Select the text and press Ctrl+B to format the text as bold.
5. Press Enter and type Script: .
6. In Controls, click InputText Box.
7. In Links & Data, click Assignment and then in Text, select Business Entities > Generic HTML Functions > Script.

8. Similarly, add Title and URL.
9. Add the sample text.

Step 4: Create an Event Handler

Next, you need to create a callout that launches when the solution is loaded.

1. In Business Logic > Event Handlers, create a New Event Handler and name it OpenCallOut.
2. From When the following event is raised, select Administration is Solution Loaded.
3. Select Insert Instruction > Function Invocation and then click Select Function, and select Callouts > Generic HTML Functions > Show.

Step 5: View the Results

1. Ensure that only one browser is open with the required web page.
2. Run the project. Enter (or copy paste) a Script and a URL or Title, and click Eval Scrip with Result to execute the function. The script is executed.