Related Topics
bp Class
This object represents the SDK environment. All scripts will have access to this object. This class contains many methods that implement utility routines (such as logging, data conversion, etc).
Methods


This API will force the process engine to start the task advance check logic.
Parameters
WFINSTID: Optional Workflow Instance ID to check.
PRINSTID: Optional Timeline Instance ID to check.
WFID: Optional Workflow Definition ID to check.
PRID: Optional Timeline Definition ID to check.
Returns
None.
Example
bp.CheckForAdvance(ProcessInstanceID, null, null, null);


This API will determine the value of the difference between two dates.
Parameters
BP: The bp environment.
DateFrom: The origin (starting) date
DateTo: The termination (ending) date
DifferenceType: The type or units of difference to calculate (e.g. days, seconds, hours, years)
Returns
int: An integer representing the value of the difference between the two dates in the specified units.
Example
// Should return the value '4'
int days = bp.DateDiff(bp, DateTime.Parse("2022-03-05"),
DateTime.Parse("2022-03-09"),
BPLogix.WorkflowDirector.SDK.FormControls.DateDiffType.Days);


This boolean property returns the status of the Process Director Database.
This can be used, for example, prior to making SDK calls that may access the database in the custom vars file.
Parameters
none
Returns
boolean: This property returns true if the Process Director database has been successfully opened.
Example
// Called after database initialized
public override void SetSystemVars(BPLogix.WorkflowDirector.SDK.bp bp)
{
// Before we make SDK calls that access the database,
// ensure DB has been opened
if (bp.DBOpenComplete)
{
// Routine to perform if true
}
}


This API will return a string that is formatted as a currency.
Parameters
Any integer, double, decimal, or string
Returns
string: The object formatted in a currency (depending on locale)
Example
string TempString;
// Returns $100.00 (assuming USA locale)
TempString = bp.FormatCurr("100");
// Returns $10.10 (assuming USA locale)
TempString = bp.FormatCurr(10.1);
// Returns ""
TempString = bp.FormatCurr("Bad Value");


This API imports an Excel file into memory.
Parameters
ExcelPath: The server local path to the Excel file to import (specify this or ExcelDID).
ExcelDID: The ID of the document in the repository of the Excel file to import (specify this or ExcelPath).
SheetNumber: Zero-based sheet number to import (specify this or SheetName).
SheetName: Sheet name to import (specify this or SheetNumber).
Returns
list<bpExcelRow>: List of excel rows, or null if any error
Example
// This will import an Excel file
var Rows = bp.GetExcelRows( "C:\\db_import.xlsx", // The file path to import
null, // null since we are using a file path
0, // The first sheet in the workbook
null); // Null since we are using SheetNumber
// instead of SheetName
if (Rows != null)
{
foreach (var Row in Rows)
{
foreach (var Col in Row.Columns)
{
bp.log0("Column value: " + Col.Value + ", Column type: "
+ Col.Type);
}
}
}


This API will return a string for a temporary file name. It will use random digits to ensure the name is unique.
Parameters
An optional string to prepend, and optional string to append
Returns
string: The string of a unique temporary file name and path.
Example
var TempFileName = bp.GetTempFilePath("begin","end");


This API will POST a URL and return the XML response as a string
Parameters
string (URL): the URL to POST
string (XML Data): request data to POST (typically XML)
Returns
string: String variable containing response from page – typically in XML.
Example
// This will POST a request and get back the response
bp.HTTPRest("http://myserver.com/pagetopost.aspx","<API>1</API>");


This API import an Excel file into a database. The sheet name will be used as the table name in the database. Only sheets with data in cell A1 will be imported. Row 1 in Excel is used to specify the column name in the database. You can optionally specify a column type for each column by separating the column name from the type with a colon. You can use several database independent column types, such as"
-
BP_STRING
BP_DECIMAL
BP_BOOL
BP_INT
BP_DATETIME
If you don't specify a type, the import process will guess at the type by looking at the first row of data. Since the worksheet must have a header row to supply column names and optional data types, the first data row will be row 2 of the worksheet.
Parameters
BP: The bp environment.
DestDB: The DataSource of the database to insert the Excel data.
ExcelPath: The server local path to the Excel file to import (specify this or ExcelDID).
ExcelDID: The ID of the document in the repository of the Excel file to import (specify this or ExcelPath).
TBLPrefix: Optional prefix to add to all imported tables.
DropFirst: Should the tables be dropped before importing?
DoCreate: Should the tables be created during the import?
DeleteFirst: Should the rows be deleted before the import?
Returns
Boolean: True if the operation succeeds.
Example
// This will import an Excel file into the database
bp.ImportExcelDatabase(bp,
dbConnection, // The database to insert the Excel data
"C:\\db_import.xlsx", // The file path to import
null, // null since we are using a file path
"USER_", // All tables created will have USER_ prefix
true, // drop existing tables first
true, // create all tables in database
false); // no need to delete rows –
// entire tables were dropped


These functions import XML data from an XML file that Process Director exported. They mainly take the same parameters, but interpret the XML in different ways:
- ImportXML: reads the XML data into a file in the content list.
- ImportGlobalKViewXML: reads the XML file into a global Knowledge View.
- ImportProfilesXML: reads the XML file into a profile definition.
The method declarations are as follows:
public bool ImportXML(string XMLPath,
string XMLDID,
byte[] XMLData,
string PID,
string ParentFolderID,
out List<string> RetMsg)
public bool ImportGlobalKViewXML(string XMLPath,
string XMLDID,
byte[] XMLData,
out List<string> RetMsg)
public bool ImportProfilesXML(string XMLPath,
string XMLDID,
byte[] XMLData,
out List<string> RetMsg)
Parameters
string XMLPath: The file path of the XML file.
string XMLDID: The document ID of the XML file.
byte []XMLData: The raw XML data.
string PID: ID of the partition in which to import this XML document.
string ParentFolderID: The ID of the folder that this XML document will be imported into.
out List<string> RetMsg: A list of messages returned by this function.
Returns
boolean: This function returns true if, and only if, the import is successful.
Example
//imports XML File
List<string> returnMessages = new List<string>();
bool success = bp.ImportXML("someXMLFile.xml", "1234", "1234",
returnMessages);


These APIs will send a logging message to the bp.log file. This file can be viewed on disk, or you can use the web based log viewer. log0 will always be sent to the log file. The other methods will be sent to log file depending on the system log level setting.
The actual log will be written conditionally depending on the current logging level of the system. log0 will always be written, log1 will only be written if the logging level is 1 or higher, etc.
More information about logging can be found in the System Administrator's Guide.
Parameters
Any formatted string or string variable.
Returns
None
Example
bp.log0("This is a test");
bp.log0("Some sample data " + CurrentForm.FormControl("mydata").Text;
bp.log0(“Data1: {0} Data2: {1}”, 10, 20);


This API will login as the specified user.
Parameters
BP: The bp environment.
User: The UserID to login.
Password: The password to login.
Returns
boolean: True if the operation succeeds.
Example
// This will login the user from the edit fields on a form
bp.Login(bp, CurrentForm.FormControl("userid"),
CurrentForm.FormControl("password"));


This API runs a Knowledge View and returns the found rows of Content items.
Parameters
KVID: The Knowledge View ID to run.
Filter: List<NameValue> - Optional list of input filter to the Knowledge View. Use {var:PARM} in the Knowledge View definition to access the filter fields.
StartFID: Optional Folder ID to filter.
StartCATID: Optional Category ID to filter.
Output: List<KViewResult> - List of resultant rows
Returns
boolean: True if the operation succeeds.
Example
In order for the RunKView method to execute properly, the Knowledge View definition must have the appropriate system variable set as a filter. In the case of the example below, the Knowledge View must use the value of "Filter1" set as a filter. For instance, let's say you wish to find the value of a filter named "Filter1" in a Form field. In that case, your filter in the Knowledge View definition might look something like this:
The RunKView method will pass the filter value in the Filter parameter, which is identified by the "infilter" variable in the code snippet below.
// Run a Knowledge View, then log the results
var infilter = new List<NameValue>();
infilter.Add(new NameValue("Filter1","Value"));
List<bp.KViewResult> rows;
var res = bp.RunKView(CurrentForm.FormControl("kview_picker").Text, infilter,
null, null, out rows);
if (res)
{
foreach (var row in rows)
{
bp.log0("ID: " + row.ID + " type: " + row.ObjectType);
foreach (var col in row.Columns)
{
bp.log0("Column Name: " + col.Name + " Value: " + col.Value);
}
}
}


This API will send an email. This is an overloaded method, and the method declarations are as follows:
public static bool SendEmail(bp BP,
string pFORMID,
string pFORMINSTID,
List<ContentObject> pAttachments,
string pSubject,
string pToEmailUID,
string pFromEmailAddress
public static bool SendEmail(bp BP,
string pFORMID,
string pFORMINSTID,
List<ContentObject> pAttachments,
string pSubject,
string pToEmailAddress,
string pToEmailDisplay,
string pFromEmailAddress)
Parameters
BP: The bp environment.
FORMID: The form ID to use as the email template.
FORMINSTID: The ID of the form instance to be used for variable substation in the email. Specify “null” if you don't wish to reference a form instance.
Attachments: A list of ContentObject attachments to add to the email
Subject: The subject of the outgoing email
ToEmailUID: The UID of the destination
FormEmailAddress: The email address of the sender of the email
Returns
boolean: True if the operation succeeds.
Example
bp.SendEmail(bp,
oMyFORM.ID, // The email template
oMyFORMINST.ID, // The form instance
null, // list of attachments
"My Email Subject", // Subject
newuser.UID, // The ID of the “to” for the email
“from_email@company.com”); // The “from” email address/
Documentation Feedback and Questions
If you notice some way that this document can be improved, we're happy to hear your suggestions. Similarly, if you can't find an answer you're looking for, ask it via feedback. Simply click on the button below to provide us with your feedback or ask a question. Please remember, though, that not every issue can be addressed through documentation. So, if you have a specific technical issue with Process Director, please open a support ticket.