Starfish Scripting Class
From within VBScript operations (ScriptedVariable, VBScriptProcedure, ScriptedField) in additional to normal VBScript functions, the developer has access to a custom “Starfish” class. The tables below define its usage. This class may also be used with C# scripting.
Class Properties
You can use these class properties like you would use a variable in your code. For example, you could have VBScript where you wanted to see if you were running or Previewing, so you could do If PreviewMode = True Then...
Property Name | Description |
---|---|
CurrentStageName | Read-only. Returns the name of the current stage. Useful during “Repeat Each Stage” Exec Operations to determine path of execution/next steps. |
TotalRows | Returns the total number of Origin Rows in the job. |
CurrentRow | Returns the current row number. |
ReturnValue | Sets the return value to the calling application. Useful for passing an output back when the Job was called with an argument. |
Origin ( String ) | Returns the current Origin row’s value for the field specified. |
PreviewMode | This boolean variable can be used to determine if you are Previewing or Running a Job. Returnes True of False. Ex: If PreviewMode <> True Then... |
Class Methods
Custom Engine Settings & Variables Class Methods
These values can be seen and modified on the General tab in Starfish. The values are stored in a local SQLite database, C:\inetpub\wwwroot\StarfishEngine\engine.db.
Method Name | Description |
---|---|
GetSetting(name As String) As String | Use this to retrieve an engine variable. |
SaveSetting(name As String, value As String) As Boolean | Use this to set an engine variable. |
Starfish Stage & Job Control Class Methods
Method Name | Description |
---|---|
GotoStage ( String ) | Directs Starfish Engine to go directly to a Stage (skipping any others before it). String Parameter is the Name of the stage to go to. Once GotoStage has been called within a Job, it is considered in a “manual operation mode”. No more stages will be called in order and it will be up to the user to implement a After Each Stage Exec Operation to control stage flow. If no After Operation is called, it will go to the next row after the stage runs. |
GotoJob ( String ) | Directs Starfish Engine to go directly to a Job. Pass in the GUID of the Job found on the General Tab, "Current Job ID". Please use with caution. |
GotoNextRow () | Skips all Stages and moves to the next Origin row. |
EndJob ( String ) | Cancels the Job execution immediately, ending with an error message as passed into the String param. |
Lookup and data retrieval Class Methods
Method Name | Description |
---|---|
GetFields ( String ) | Executes a SQL SELECT statement returns all field values from the first row, comma-delimited. VBScript Split() function may be used to convert to an array within your function. Can improve performance when needing multiple fields from a single table. |
ExecScalar ( String, String(Optional) ) | Executes a SQL SELECT statement on the Destination database. Returns the first column of the first row returned by the query. Compatible with OLE DB destinations.
There is an optional parameter to query the origin. To query the origin, use the second parameter of "ORIGIN"EX: ExecScalar("select id from company", "ORIGIN") |
ExecScalarCache ( String ) | Same as ExecScalar, except that results are cached and before a query is executed, a search is performed on a locally-stored set of results to prevent execution of identical queries, thus boosting performance. Should only be used for queries where multiple identical queries may be run (such as looking up user id’s or picklist values) – otherwise could consume resources needlessly. |
ExecSQL ( String, String(Optional) ) | Executes a non-query statement, such as UPDATE or DELETE against the destination database. Returns number of rows affected. Compatible with OLE DB destinations. First parameter is SQL Statement. Second parameter is optional connection to run again. "DESTINATION" is default, other option is "ORIGIN". |
SmartLookup ( String, String, String, [Boolean], [String], [String] ) | Performs a lookup against the destination database, and returns one field value based on supplied filter.
String – Table to perform lookup in String – Name of field to return String – Filter code (such as Where clause, not including keyword “Where”) Boolean – Default False. Enable cache for this lookup. String – Default Blank. Order By String – Default "DESTINATION". Use "ORIGIN" to query the Origin. |
SmartQuery ( String, [String], [String]) | Performs a lookup query against the destination database, returns all columns and all rows from query as a multi-dimensional array.
String – Table to perform the query in String – Filter code String – Default All Columns. Comma-separated list of columns to return If both last 2 parameters are left blank, SmartQuery performs a full operation as specified in the first parameter. |
Other Class Methods
Method Name | Description |
---|---|
LogMessage ( String, MsgBoxStyle ) | Appends a custom message to the Log which will always be displayed (even if Logging Level is set to None). Message is the passed in String parameter. Second parameter is a valid MsgBoxStyle (vbInformation, vbQuestion, vbExclamation, vbCritical) |
SendEmail ( String, String, String, [String], [String], [String], [String], [Boolean] ) | Sends an email directly from within the VBScript function/procedure. SMTP Server settings are pulled from the values entered on the General tab.
Parameters: (String) To_Addr – Email Recipient Address(es), separate multiples with ";" (String) Subject – Subject of the Email (String) Body – Body of the Email (Optional, String) From Address (default is what's entered on the general tab) (Optional, String) From Display (default is what's entered on the general tab) (Optional, String) CC Address(es) (Optional, String) BCC Address(es) (Optional, Boolean) Body Format HTML (default is false - plain text) |
ParseName ( String, String ) | Parses as string containing a person’s name, and returns the part of the name requested.
Parameters: String – Input String containing entire name Part – Part of the name to return. Valid parts are “Title”,”First”,”Last”,”Middle”,”Pedigree”,”Degree”. |
RemoveIllegalXMLCharacters ( String ) | This function removes Illegal XML Characters from a string. This function can be used on a string before inserting it into the Target to resolve the "error in msg parsing: XML error parsing SOAP payload on line 32: Invalid character" error. |
GetStageValue ( Integer, String) | Returns the destination value used on a previous stage.
Integer – Index number of the stage, 0-based. String – Field name of the value from this stage to return. For some of the CRM Native API’s (SData, Microsoft), generated ID’s will be automatically stored in a field named “Key”. |
BlackbirdMessage ( String, String, String, String, [String], [String] ) | Send a Blackbird Alert message (server is specified in Web.config)
String – Message Title String – Message Text/Body String – To (user or group to receive message) String – URL where message link will forware to String – Icon, Default “Info”. Choose from: Info, Warning, Error, Question, Star, Check, Search, Globe, Phone, Users, Lock, Task, Bell, Cellphone, Envelope, Calendar, Flag, Charts, Calculator, Fax String – System, Default <blank>. Name of External System for use with To-ID matching. |
IsEmailValid ( String ) | Returns True if supplied email address is in a valid email format; otherwise false. |
FormatDate ( String, String ) | Returns date in supplied format.
String – Date to format String – Format String Example: newdt = FormatDate(olddt, “yyyy-MM-dd hh:mm:ss”) |
File Class Methods
Method Name | Description |
---|---|
MoveFile ( String, String ) | Moves a file on the server.
String – From filename path String – To filename path |
CopyFile ( String, String ) | Copies a file on the server.
String – From filename path String – To filename path |
DeleteFile ( String ) | Deletes a file on the server.
String – Filename path |
ReadFile ( String ) | Reads a file in text mode and returns the contents as a string.
String – Filename path |
WriteFile ( String, String ) | Writes the supplied contents to a file in text mode. Entire file is overwritten.
String – Filename path String – contents to write to the file |
XREF Class Methods
Method Name | Description |
---|---|
XrefInitWrite ( String ) | Initializes a cross-reference file for writing. If file exists, new data will be appended to it.
String – cross-reference name |
XrefInitRead ( String ) | Initializes an existing cross-reference for reading. This reads all ids into memory so they will be available within your job.
String – cross-reference name |
XrefWrite ( String, String, String ) | Writes a new ID reference entry to an initialized file.
String – cross-reference name String – ID 1 (the ID you’ll look up by in future jobs) String – ID 2 (the ID you’ll want returned by future lookups) |
XrefRead ( String, String ) | Reads an ID entry from an initialized file. (Returns ID 2 from above)
String – cross-reference name String – ID 1 |
MS Dynamics CRM Specific Methods
Method Name | Description |
---|---|
GetMCRMPicklistValue( String, String, String ) | Returns the integer value for a supplied picklist string.
String – Entity for the picklist (“account”) String – Fieldname of the picklist (“accounttype”) String – Value for the picklist (“Prospect”) |
MCRMSetRelationship ( String, String, String, String, String ) | Sets a relationship between two entites.
String – Relationship Name String – Entity 1 Name String – Entity 1 ID String – Entity 2 Name String – Entity 2 ID |
SugarCRM (SOAP) Specific Methods
Method Name | Description |
---|---|
SugarSetRelationship (String, String, String, String ) | Sets a relationship between two modules. Returns True or False based on the success of creating a relationship.
String – Module 1 Name String – Module 1 ID String – Module 2 Name String – Module 2 ID |
SugarSetRelationshipv4 (String, String, String, String, Number(Optional) ) | Sets a relationship between two entities, compatible also with custom modules. Returns True or False based on the success of creating a relationship. Also able to remove a relationship between two entities with the optional fifth parameter.
String – Module 1 Name String – Module 1 ID String – Relationship Name String – Module 2 ID String – [Delete] (Optional) – Default is 0 (false). Set to 1 (true) to Delete a relationship. |
SugarGetRelationships ( String, String, String ) | Gets comma-separated a list of ID’s related to an entity
String – Module 1 Name String – Module 1 ID String – Module 2 Name |
SugarGetRelationshipsv4 ( String, String, String ) | Gets comma-separated a list of ID’s related to an entity
String – Module 1 Name String – Module 1 ID String –Relationship Name |
Email (IMAP) Specific Methods
Method Name | Description |
---|---|
MoveIMAPMessage ( String ) | Moves the current email message to the specified folder on the server.
String – Name of IMAP folder to move message to |
Conversion Methods
Method Name | Description |
---|---|
ConvertRTFToText ( String ), ConvertHTMLToText ( String ), ConvertBase64ToBytes ( String ) | Converts the String supplied. |
SQLite Class Methods
Method Name | Description |
---|---|
SQLiteInsert | Returns boolean, true if successful: b = SQLiteInsert("test_table", "field1,field2", "'@@ORG:DirectoryRelative@@','@@ORG:Name@@'") |
SQLiteSelect | Returns a multi-dimensional array: b = SQLiteSelect("test_table", "field1,field2", "field2='@@ORG:Name@@'") EX: if UBound(b)>-1 then 'there is data logmessage b(0,0) logmessage b(0,1) else logmessage "no data" end if |
SQLiteUpdate | Returns boolean, true if successful: b = SqliteUpdate (table, update_values, where) EX: SqliteUpdate ("blah", "textfield1='hey', numfield3=45", "name=@@ORG:Name@@") |
SQLiteDelete | Returns boolean, true if successful: b = SQLiteDelete("test_table", "field2='@@ORG:Name@@'") |
JSON Methods
Method Name | Description |
---|---|
ParseJson( String ) | Loads the passed in string into the JSON parser. |
GetJSON( String, [String], [String], [String], [String], [String], [String], [String], [String] ) | Returns a given section from the supplied JSON. |
JSONArrayCount( ) | Returns the number of elements within the JSON array loaded using ParseJson. |