Knowledge View Scripts

This section provides a reference for writing custom Knowledge View scripts for Process Director. The Knowledge View supports a custom script that can be called before the results are displayed to the user. The custom scripts are stored in the Process Director database in the Content List. The custom script is used to inspect, modify, calculate, or remove results from the Knowledge View.

To develop Knowledge View Scripts inside Visual Studio, use the fully functional Visual Studio project installed with the product named bpVS.zip. Refer to the sample file kview_script.ascx.

Writing a Knowledge View Script Function

A Knowledge View can have a custom script that can alter the results of the displayed information.

When the Knowledge View runs, it will call this method in the script for EVERY row in the result:

public override bool KV_Display(List<NameValueEx> pColumns,
                                ContentObject pObject,
                                out bool pRemoveRow)

If you set the pRemoveRow to true, then the row being processed will be excluded from the report.

The example below will add the HTML “bold” tag around the value for the Amount columns.

<%@ Control Language="C#" AutoEventWireup="false"
    Inherits="BPLogix.WorkflowDirector.SDK.bpScript" %>
<%@ Import Namespace="System.Collections.Generic" %>
<%@ Import Namespace="BPLogix.WorkflowDirector.SDK" %>
<script runat="server">
    public override bool KV_Display(List<NameValueEx> pColumns,
                                    ContentObject pObject,
                                    out bool pRemoveRow)
    {
        pRemoveRow = false;// Do not remove the row being processed
        foreach (var entry in pColumns)
        {
            // Bold the Amount column
            if (entry.Name == "Amount")
            {
                entry.Value = "<b>" + entry.Value + "</b>";
            }
        }
        return true;// Return true if a value has changed
}
</script>

Notice that Knowledge View scripts inherit from  BPLogix.WorkflowDirector.SDK.bpScript.

This method will be called with the following environment:

LOCAL VARIABLE

DESCRIPTION

CurrentUser

Optional instance of the current User object

CurrentPartition

Instance of the current Partition object

bp

The bp environment

NameValueEx List Object

Note that the Knowledge View script uses the NameValueEx list object to store the values in each of the Knowledge View columns. The Value attribute of the NameValueEx list is always a string, but, of course, the value may be derived from a non-string object. Let's say that a value we wish to find comes from a checkbox. In that case, we would see the Value of the checkbox represented by the string values "True" or "False". If the Value contains a string representation of a number, on which you'd like to do some math, you can use the built-in Process Director conversion methods to convert the Value string to an appropriate numeric value.

In addition to the Value attribute, however, the NameValueEx list class also has a ValueEx attribute that contains the actual .NET DataItem object for the field, or a decminal number.

The NameValueEx object constructor has four overloads:

//Null values
public NameValueEx()

//String Name and Value
public NameValueEx(string pName, string pValue)

//String Name and Value, and Decimal Number
public NameValueEx(string pName, string pValue, decimal pNumber)

//String name and Value, and List DataItem
public NameValueEx(string pName, string pValue, DataItem pDataItem)