Starfish Scripting Class

From Starfish ETL
Revision as of 15:36, 6 October 2014 by Jkuehlthau (talk | contribs) (Created page with " From within VBScript operations (ScriptedVariable, VBScriptProcedure, ScriptedField) in additional to normal VBScript functions, the developer has access to a custom “Star...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

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


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


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.



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.



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)



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



Executes a non-query statement, such as UPDATE or DELETE against the destination database. Returns number of rows affected. Compatible with OLE DB destinations.



SendEmail ( String, String, String )



Sends an email directly from within the VBScript function/procedure.


Parameters:


To_Addr – Email Recipient Address


Subject – Subject of the Email


Body – Body of the Email



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”.



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.



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



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”)



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



MS Dynamics CRM-Specific



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-Specific



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



MoveIMAPMessage ( String )



Moves the current email message to the specified folder on the server.


String – Name of IMAP folder to move message to