Bots

Prior to version 6.3, ActivityHD employed tools such as Excel to perform automation tasks in ActivityHD. While those tools are still available, version 6.3 introduced the ability to define bots (formerly called macros) within ActivityHD Explorer. To use a specific bot, users must be assigned permissions to the bot. Currently, there are six bot types: class, module, general, record, record list, and record loop.

A shortcut key combination can be assigned to the bot to make it easy to execute. (When you assign shortcuts, be sure to avoid conflicts with other ActivityHD shortcuts.)

Bots security

Common accesses available on bots

Access A user with this access can...
Change Use the mass change action on bots.
Change Logs  
Custom Fields Create and edit custom fields for bots.
Data Have read-only access to bots from anywhere in the software (e.g., field validations, filters, date expressions).
Delete Delete bots.
Edit Edit bot records.
Export Export bot records from ActivityHD.
Import Import bot records into ActivityHD.
New Create new bot records.
Read Have read-only access to bot records.
Report Run reports with bot information.
Report Designs Create and edit report designs with bot information. This access enables the Report Designs button on the Output tab of report dialogs.
Shared Answers Create and edit saved answers related to bots.
Shared Filters Create and edit shared filters on bots.
Visible View the Bots folder in the Navigation pane.

Special accesses available on bots

Access A user with this access can...
Run Run a bot.

MacroProcess

The MacroProcess context object provides information about the bot being run and allows messages and results to be be shown.

MacroProcess properties:

  • Activity
  • Attachments
  • Company
  • MacroID: Variant - The internal identifier (GUID) of the bot object being run
  • MacroName: Variant - The name of the bot being run
  • Options
  • OptionValues
  • RecordList
  • Results: IDataResults - Gives access to the IDataResults interface which is used to display result records. Available when the Enable Results checkbox is marked.

MacroProcess methods:

  • AddMessage(Value: String) - Add text messages to be displayed to the user
  • AddMessages(Value: String array or string) - Add text messages to be displayed to the user
  • CreateObject(ByVal ObjectName As String) As Object

Node package: ahd_emails

How it works

  • Allows the Log object to be passed from ahd_logger each time the add() method is used. If it is not passed, console.log is used instead.
  • Allows FileOnly to be passed in the add() method to log only to the file for auditing purposes (e.g., add(category, method, FileOnly=null)). This is ignored if a Log object is not passed.
  • Allows selection of three standard categories and dynamic creation of other categories. The color scheme by category is:
    CategoryColor
    UpdatesGreen
    ErrorsRed
    InfoBlue
    OtherGray
  • The sendEmail() method can be called to distribute email to all specified recipients. Customization of recipients, operation, company name, subject, from, and sending method are available.

Example using ahd_emails package

Copy snippet
const { Log, FileOnly } = require("ahd_logger");
const EmailUpdates = require("ahd_emails");
const updates = new EmailUpdates(Log);

updates.add("Errors", {
title: "Payroll sync",
category: "Employee update failed",
message: "Employee ID 12345 missing email"
}, FileOnly);

updates.add("Updates", {
title: "HR import",
category: "Employee updated",
message: "Employee ID 67890 updated successfully"
}, FileOnly);

updates.add("Info", {
category: "Process started",
message: "Employee sync initiated at 9:00 AM"
}, FileOnly);

updates.add("Miscellaneous", {
category: "Process completed",
message: "Final Message"
});

const emailInfo = {
toAddress: ["[email protected]"],
operation: "WFH Employee Update",
subject: "Daily Employee Update Results",
from: "Server Generic",
companyName: Company.Name,
};

updates.sendEmail(emailInfo);

Log.close();
                

Node packages: csv-parser vs. papaparse

While csv-parser and papaparse both parse csv files, ActivityHD retains both because each has its own benefits.

Benefits of csv-parser:

  • ideal for large files
  • ideal for streaming and performance
  • simple pipelines

Benefits of papaparse:

  • handles messy/inconsistent csv files better
  • allows built-in parsing intelligence
  • easier transformations

So csv-parser does the work without bells and whistles and does it efficiently. Papaparse does the work but has the mechanisms for working on data while parsing AND it handles all the rough edge cases. The trade-off with papaparse is that it is not as fast and efficient. Since both parsers have their purposes, both are distributed.

Node packages: ahd_logger

Purpose: Allows scheduled/offline bots to create an ActivityHD note at the end of a run, providing a visible curated summary in the app with no need for a user to watch the window.

The following improvements are available in ahd_logger 2.1.0:

New API

Log.setNoteTarget(packageCode, ntName?). Call early in the bot to configure where the note is created. Supported packages are AP, AR, FA, PR. If NoteType does not exist, it is automatically created. Invalid package codes log a warning and set no target.

Log.logNote(message, settings?). Logs a key milestone or result. Outputs to log file and window at INFO level. Adds to the note buffer for inclusion in the final note.

Behavior changes

logError() automatically pushes "[ERROR] message" into the note buffer with no extra call needed.

close() creates the note if a target is set and the buffer is not empty. The note body includes bot name, start/end timestamps, error status, a divider, then all buffered lines. The Description field is set to "BotName - Completed (N error(s))" for at-a-glance status in the notes list.

No note is created if setNoteTarget() is never called or if the buffer is empty.

Internal additions

createNote(packageCode, ntName, description). Creates the NoteType (idempotent) and a new note record.

writeToNote(text, note). Appends content to the NoteText field, falling back to NoteRemark.

SUPPORTED_NOTE_PACKAGES constant

noteBuffer and noteTarget properties on LogObj

Tests and docs

385-line expansion to the unit test file covering noteBuffer, setNoteTarget validation, logNote, and logError auto-buffering.

README and AHD bot test file have been updated with usage examples and the "Scheduled Bot Example" pattern.