Ask Coach

Turn a rough idea into a plugin


  

Scripting: actions that run inside the ACT! desktop

Scripts run while ACT! is open, so they can work with the user interface and the record the user is currently viewing. This includes the Current Contact, Current Company, Current Group, and Current Opportunity.
When Impact AI Studio runs a script, your code is inserted into an EvalRunTime class and compiled as C#. You do not need to create this class yourself. Your script is placed inside the EvaluateIt method, where it can use the ACT! application, framework, current form, current custom record, and the helper methods documented below.

Basic compiled structure

The following simplified example shows where your script is placed. The objects and helper methods are already available to your code.

class EvalRunTime { private Act.UI.ActApplication HostApplication; private Act.UI.ActApplication App; private Act.Framework.ActFramework HostFramework; private System.Windows.Forms.Form Form; private Act.Framework.CustomEntities.CustomSubEntity Record; private Act.Framework.CustomEntities.CustomSubEntity SubEntityItem; private Act.Framework.CustomEntities.CustomSubEntityManager<Act.Framework.CustomEntities.CustomSubEntity> EntityManager; public object EvaluateIt(...) { // Your code is inserted here return Script.CreateHistory( App, "Call", "Call Left Message", "Follow Up - Support Request", ""); } }

Objects available inside your script

App

The current ACT! application object. Use this for most Script. functions and ACT! user-interface actions.

HostApplication

The same ACT! application object as App. Both names point to the current ACT! application.

HostFramework

The current ACT! framework and database connection. Use it to access ACT! managers, lookups, contacts, companies, groups, opportunities, and field descriptors.

Form

The Windows Form associated with the script. It may be used to find or work with controls on the current form.

Record

The current custom-table record when the script is running from a custom entity. It is also the record used by the short GetValue and SetValue overloads.

SubEntityItem

An alternate reference to the current custom record. It is used by the Product/custom-subentity field update logic.

EntityManager

The manager for the current custom entity. It supplies custom field descriptors and information about the current custom table.

Important: Although the helper methods are declared private in the compiled class, your inserted code can call them because your code runs inside that same class.

EvaluateIt

EvaluateIt

The entry point executed by the scripting engine. Impact AI Studio supplies all parameters, assigns them to the built-in class fields, runs your inserted code, and then updates the current custom record when one is available.

Compiled signature
public object EvaluateIt( Act.UI.ActApplication HostApplication, Act.Framework.ActFramework HostFramework, System.Windows.Forms.Form Form, Act.Framework.CustomEntities.CustomSubEntity Record, Act.Framework.CustomEntities.CustomSubEntityManager<Act.Framework.CustomEntities.CustomSubEntity> EntityManager)
Parameters
Parameter How it is used
HostApplication The active ACT! application. The class assigns it to both HostApplication and App.
HostFramework The active ACT! framework/database object.
Form The Windows Form associated with the script.
Record The current custom-table record, when applicable. It is assigned to both Record and SubEntityItem.
EntityManager The custom entity manager associated with Record.
Returns
An Object. Your script may return a Boolean, String, number, ACT! object, or null. The appropriate return value depends on where and how the script is used.
Example
return Script.CreateHistory(App, "Call", "Call Left Message", "Follow Up - Support Request", "");

Reading field values

GetValue(tableName, displayName)

Reads a field from the current ACT! contact, company, group, or opportunity.

Syntax
object value = GetValue("Contact", "Company");
Parameters
Parameter How to use it
tableName Use "Contact", "Company", "Group", or "Opportunity". The current record for that ACT! entity is used.
displayName The ACT! field's display name, such as "Company", "City", or "Estimated Close Date". Matching is not case-sensitive.
Returns
The field value as an Object. When a value is null, Contact and Company fields return a type-appropriate default: zero for numbers, False for Yes/No, DateTime.MinValue for dates, or an empty string for text. Group and Opportunity null values return an empty string.
Examples
string city = GetValue("Contact", "City").ToString(); decimal amount = Convert.ToDecimal(GetValue("Opportunity", "Total"));
GetValue(tableName, displayName, record)

Reads a field from a specific ACT! contact, company, group, or opportunity object instead of the current record.

Available overloads
object value = GetValue("Contact", displayName, contact); object value = GetValue("Company", displayName, company); object value = GetValue("Group", displayName, group); object value = GetValue("Opportunity", displayName, opportunity);
Parameters
Parameter How to use it
tableName Identifies the ACT! entity. In these overloads, field descriptors are selected by the record object's entity type.
displayName The ACT! field display name. Matching is not case-sensitive.
contact / company / group / opportunity The specific ACT! record whose field value should be returned.
Returns
The selected field value as an Object. A missing field or unavailable value returns an empty string or the type-appropriate default used by the overload.
Example
foreach (Act.Framework.Contacts.Contact contact in HostFramework.CurrentLookupContactList) { string city = GetValue("Contact", "City", contact).ToString(); }
GetValue(displayName)

Reads a field from the current custom-table record stored in Record.

Syntax
object value = GetValue("Status");
Parameters
Parameter How to use it
displayName The custom field's display name. Matching is not case-sensitive.
Returns
The custom field value as an Object. Null values are converted to zero, False, DateTime.MinValue, or an empty string according to the ACT! field type.
Example
string status = GetValue("Status").ToString();
GetValue(displayName, subEntity, entityManager)

Reads a field from a specific custom-table record using that record's custom entity manager.

Syntax
object value = GetValue("Status", subEntity, entityManager);
Parameters
Parameter How to use it
displayName The custom field's display name.
subEntity The specific custom record to read.
entityManager The manager that supplies the field descriptors for that custom record.
Returns
The custom field value as an Object, with type-appropriate defaults when the value is null.
GetValueParent(tableName, displayName)

Reads a field from the parent custom record of the current custom-table record.

Syntax
object value = GetValueParent("Parent Table", "Status");
Parameters
Parameter How to use it
tableName A descriptive table name retained by the method signature. The implementation finds the parent from the current Record and EntityManager.
displayName The display name of the field on the parent custom record.
Returns
The parent field value as an Object. Returns an empty string when no parent, field, or value is found.

Writing field values

SetValue(tableName, displayName, value)

Sets a field on the current ACT! contact, company, group, opportunity, product/custom subentity, or current custom-table record.

Syntax
SetValue("Contact", "Status", "Active"); SetValue("Opportunity", "Probability", 75); SetValue("Service Requests", "Priority", "High");
Parameters
Parameter How to use it
tableName Use Contact, Company, Group, Opportunity, or Product. For the current custom entity, you may also use its internal name or display name.
displayName The field's display name. Matching is not case-sensitive.
value The new field value. Currency and decimal fields are converted to Decimal, number fields to Integer, Yes/No fields to Boolean, and text fields to String.
Returns
An Object containing an empty string. Call this method for its update action rather than its return value.
For Contact, Company, Group, Opportunity, and Product records, the method immediately calls the record's Update() method after setting the field.
SetValue(displayName, value, record)

Sets a field on a specific ACT! contact, company, group, or opportunity object.

Available overloads
SetValue(displayName, value, contact); SetValue(displayName, value, company); SetValue(displayName, value, group); SetValue(displayName, value, opportunity);
Parameters
Parameter How to use it
displayName The ACT! field display name.
value The new value. The method converts common ACT! data types before assigning it.
contact / company / group / opportunity The specific ACT! record to change.
Returns
True after the matching field is processed. These specific-record overloads set the field but do not call the record's Update() method, so call record.Update() when the change must be saved immediately.
Example
SetValue("City", "Philadelphia", contact); contact.Update();
SetValue(displayName, value)

Sets a field on the current custom-table record stored in Record.

Syntax
SetValue("Status", "Completed");
Parameters
Parameter How to use it
displayName The current custom entity field's display name.
value The new field value. Common ACT! data types are converted automatically.
Returns
True after the field is processed. The compiled class automatically calls Record.Update() in its finally block after your script finishes.
SetValue(displayName, value, subEntity, entityManager)

Sets a field on a specific custom-table record using the supplied custom entity manager.

Syntax
SetValue("Status", "Completed", subEntity, entityManager); subEntity.Update();
Parameters
Parameter How to use it
displayName The custom field's display name.
value The new value.
subEntity The specific custom record to change.
entityManager The manager that supplies the record's field descriptors.
Returns
True after the field is processed. This overload does not call subEntity.Update(); call it explicitly when necessary.
SetValueParent(tableName, displayName, value)

Sets a field on the parent custom record of the current custom-table record.

Syntax
SetValueParent("Parent Table", "Status", "Updated");
Parameters
Parameter How to use it
tableName A descriptive table name retained by the signature. The parent record is located from the current Record and EntityManager.
displayName The display name of the field on the parent custom record.
value The new value. Common ACT! data types are converted automatically.
Returns
An Object containing an empty string. The method sets the parent field but does not explicitly call the parent record's Update() method.

Field information

GetFieldDescriptorByDisplayName

Finds the custom field descriptor for a field in the current custom entity.

Syntax
Act.Framework.CustomEntities.CustomEntityFieldDescriptor field = GetFieldDescriptorByDisplayName("Status");
Parameters
Parameter How to use it
displayName The custom field's display name. Matching is not case-sensitive.
Returns
The matching CustomEntityFieldDescriptor, or null when no matching custom field is found.
Example
var field = GetFieldDescriptorByDisplayName("Status"); if (field != null) { string physicalName = field.Name; }

Complete example using the compiled-class helpers

// Read the current contact's city string city = GetValue("Contact", "City").ToString(); // Update the current contact SetValue("Contact", "Last Result", "Called from custom script"); // Update the current custom record, when the script is running from one if (Record != null) { SetValue("Status", "Completed"); } // Create an ACT! history return Script.CreateHistory( App, "Call", "Call Completed", "Custom script completed for " + city, "");
No matching functions were found.

Connections and Integrations

OpenZapierApiRunner

Opens the Zapier/API Runner window.

Syntax
Script.OpenZapierApiRunner(App);
Parameters
Parameter How to use it
App The ACT! application object supplied by the scripting engine.
Returns
No return value.
PushContactToConstantContact

Opens the Constant Contact window for the current ACT! contact.

Syntax
Script.PushContactToConstantContact(App);
Parameters
Parameter How to use it
App The ACT! application object supplied by the scripting engine.
Returns
No return value.
GetOAuthAccessToken

Returns an OAuth access token for an external service. If the connection has not been configured, Impact AI Studio can prompt the user to connect it.

Syntax
string token = Script.GetOAuthAccessToken(App, HostFramework, "Provider Name");
string token = Script.GetOAuthAccessToken(App, HostFramework, providerName, grantType, authorizationUrl, tokenUrl, clientId, clientSecret, redirectUrl, scope, clientAuthenticationMode);
Parameters
Parameter How to use it
App The ACT! application object supplied by the scripting engine.
HostFramework The ACT! framework/database object. In most scripts this is available as App.ActFramework or HostFramework.
providerName A consistent friendly name for the connection, such as HubSpot or Microsoft Graph.
grantType The OAuth flow: authorization_code_pkce, client_credentials, refresh_token, or manual_bearer_token.
authorizationUrl The provider authorization URL. Required for authorization_code_pkce.
tokenUrl The provider token URL.
clientId The client/application ID issued by the provider.
clientSecret The client secret. Leave blank when the provider or PKCE flow does not require it.
redirectUrl The callback URL used after browser authorization.
scope The permissions requested from the provider.
clientAuthenticationMode How client credentials are sent: post_body or basic_header.
Returns
A String containing the access token. Returns an empty string when the connection is unavailable or authorization is cancelled.

ACT! Interface

OpenDesigner

Opens the Impact Designer for a selected ACT! table/entity.

Syntax
bool opened = Script.OpenDesigner(App, ACTTableName);
Parameters
Parameter How to use it
App The ACT! application object supplied by the scripting engine.
ACTTableName The ACT table enumeration value identifying the entity to design.
Returns
True when the designer opens successfully.
FindControl

Finds a control by its control name or by the ACT! field bound to it.

Syntax
Control control = Script.FindControl(App, "Contact.Company");
Control control = Script.FindControl(form, "txtCompany");
Parameters
Parameter How to use it
App Searches the current ACT! view.
form A specific Windows Form to search.
name The control Name or bound ACT! field name.
Returns
The matching Windows Forms Control, or null when no control is found.

Activities

ScheduleActivity

Opens an activity scheduling window for the current ACT! record.

Syntax
bool saved = Script.ScheduleActivity(App, "Call");
bool saved = Script.ScheduleActivity(App, "Call", "Discuss renewal");
bool saved = Script.ScheduleActivity(App, "Meeting", "Quarterly review", startTime, endTime);
Parameters
Parameter How to use it
App The ACT! application object supplied by the scripting engine.
type / atype The ACT! activity type, such as Call, Meeting, or To-do. If the type is not found, Call is used.
details The activity Regarding/details text.
starttime The activity start date and time.
endtime The activity end date and time.
Returns
True when the activity is saved; False when the user cancels.
Example
return Script.ScheduleActivity(App, "Call", "Follow up on support request");
CreateActivity

Creates an ACT! activity for the current contact. It can be created silently or opened for editing.

Syntax
bool created = Script.CreateActivity(App, "Call");
bool created = Script.CreateActivity(App, "Call", true);
bool created = Script.CreateActivity(App, "Call", "Follow up");
bool created = Script.CreateActivity(App, "Meeting", "Project review", DateTime.Now.AddDays(1), 60, true);
bool created = Script.CreateActivity(App, "Meeting", "Project review", startDate, 60, "Conference Room", "High", true, 15, true);
Parameters
Parameter How to use it
App The ACT! application object supplied by the scripting engine.
type The ACT! activity type.
regarding The activity Regarding text.
startDate The start date and time.
length The duration in minutes.
Location The activity location.
Priority The activity priority.
Alarmed True enables an alarm.
AlarmLeadMinutes Minutes before the activity when the alarm appears.
edit / open True opens the activity for review; False creates it without opening the editor.
Returns
A Boolean result. Some older overloads may return the default Boolean value after performing the action.
Example
return Script.CreateActivity(App, "Call", "Follow Up - Support Request", DateTime.Now.AddDays(1), 15, true);

Contacts, Companies, and Groups

CreateCompany

Opens ACT!'s new company screen.

Syntax
Script.CreateCompany(App);
Parameters
Parameter How to use it
App The ACT! application object supplied by the scripting engine.
Returns
Legacy Integer return; use this method for the action, not the returned number.
CreateContact

Opens ACT!'s new contact screen.

Syntax
Contact contact = Script.CreateContact(App);
Parameters
Parameter How to use it
App The ACT! application object supplied by the scripting engine.
Returns
The current ACT! Contact object after the command runs.
DuplicateContact

Duplicates the current ACT! contact.

Syntax
Script.DuplicateContact(App);
Parameters
Parameter How to use it
App The ACT! application object supplied by the scripting engine.
Returns
Legacy Integer return; use this method for the action.
AttachContact

Opens the contact picker and attaches the selected contacts to the current company, group, or opportunity.

Syntax
Script.AttachContact(App);
Parameters
Parameter How to use it
App The ACT! application object supplied by the scripting engine.
Returns
Legacy Integer return; use this method for the action.
CreateGroup

Opens ACT!'s new group screen.

Syntax
Script.CreateGroup(App);
Parameters
Parameter How to use it
App The ACT! application object supplied by the scripting engine.
Returns
Legacy Integer return; use this method for the action.
DuplicateGroup

Duplicates the current ACT! group.

Syntax
Script.DuplicateGroup(App);
Parameters
Parameter How to use it
App The ACT! application object supplied by the scripting engine.
Returns
Legacy Integer return; use this method for the action.
AttachCompany

Opens a company picker and attaches the selected company to the current record when supported.

Syntax
Script.AttachCompany(App, "");
Parameters
Parameter How to use it
App The ACT! application object supplied by the scripting engine.
CompanyName Legacy parameter. The current implementation opens the picker and does not use this value to preselect a company.
Returns
Legacy Integer return; use this method for the action.
Notes
On a contact, the selected company becomes the linked company. On an opportunity, the selected company is attached to that opportunity.
IsMember

Checks whether the current contact is related to a named group, company, or opportunity.

Syntax
bool found = Script.IsMember(App, "GROUP", "VIP Customers");
Parameters
Parameter How to use it
App The ACT! application object supplied by the scripting engine.
entityType Use GROUP, COMPANY, or OPPORTUNITY.
val The exact group, company, or opportunity name.
Returns
True when a matching relationship is found; otherwise False.
AttachGroup

Legacy attachment method that opens a company-style picker and applies the selected record based on the current ACT! view.

Syntax
Script.AttachGroup(App);
Parameters
Parameter How to use it
App The ACT! application object supplied by the scripting engine.
Returns
Legacy Integer return; use this method for the action.
Notes
Despite its name, the current implementation uses a company picker. Test it in the target ACT! view before giving it to users.

Opportunities

CreateOpportunity

Creates a new ACT! opportunity directly, or opens ACT!'s new opportunity screen.

Syntax
Opportunity opp = Script.CreateOpportunity(App, "Annual Renewal", "Sales Process:Initial Communication");
Opportunity opp = Script.CreateOpportunity(HostFramework, "Annual Renewal", "Sales Process:Initial Communication", contact);
bool opened = Script.CreateOpportunity(App);
Parameters
Parameter How to use it
App The ACT! application object supplied by the scripting engine.
HostFramework The ACT! framework/database object. In most scripts this is available as App.ActFramework or HostFramework.
OppName The new opportunity name.
OppStage The process and stage in the format Process Name:Stage Name.
contact The Contact object to attach to the opportunity.
Returns
The direct-create overloads return the new Opportunity object. The one-parameter overload returns True after opening the new-opportunity screen.
ShowOpportunity

Displays an Opportunity object or switches to the current opportunity detail view.

Syntax
bool shown = Script.ShowOpportunity(App, opportunity);
bool shown = Script.ShowOpportunity(App);
Parameters
Parameter How to use it
App The ACT! application object supplied by the scripting engine.
cOpp The Opportunity object to display.
Returns
True after the opportunity view is shown.
DuplicateOpportunity

Duplicates the current ACT! opportunity.

Syntax
bool duplicated = Script.DuplicateOpportunity(App);
Parameters
Parameter How to use it
App The ACT! application object supplied by the scripting engine.
Returns
True after the duplicate command is called.
AddOpportunityProduct

Adds a product line to the current opportunity or to a supplied Opportunity object.

Syntax
bool added = Script.AddOpportunityProduct(App, "Consulting");
bool added = Script.AddOpportunityProduct(App, "Consulting", true);
bool added = Script.AddOpportunityProduct(App, "Consulting", 2, 500, 750, 0, true);
bool added = Script.AddOpportunityProduct(App, opportunity, "Consulting", 2, 500, 750, 0, true);
Parameters
Parameter How to use it
App The ACT! application object supplied by the scripting engine.
opportunity The Opportunity object that receives the product. When omitted, the current opportunity is used.
ProductName / name The product line name.
quantity The quantity.
cost The cost per unit.
price The selling price per unit.
discount The discount value.
edit True opens the product for editing after creation.
Returns
Boolean result. In the detailed legacy implementation, False may be returned when edit is False even though the product was created.
AttachOpportunityContacts

Opens the contact picker and attaches selected contacts to an opportunity.

Syntax
bool attached = Script.AttachOpportunityContacts(App, opportunity);
Parameters
Parameter How to use it
App The ACT! application object supplied by the scripting engine.
cOpportunity The Opportunity object that receives the selected contacts.
Returns
True when the contacts are attached; otherwise False.
AttachOpportunityCompanies

Opens the company picker and attaches selected companies to an opportunity.

Syntax
bool attached = Script.AttachOpportunityCompanies(App, opportunity);
Parameters
Parameter How to use it
App The ACT! application object supplied by the scripting engine.
cOpportunity The Opportunity object that receives the selected companies.
Returns
True when the companies are attached; otherwise False.
AttachOpportunity

Opens the ACT! opportunity picker.

Syntax
Opportunity opportunity = Script.AttachOpportunity(App);
Parameters
Parameter How to use it
App The ACT! application object supplied by the scripting engine.
Returns
The selected Opportunity object, or null when the user cancels.

Documents, Histories, and Notes

AttachDocumentToContact

Adds a file to a contact's Documents/Library history.

Syntax
Attachment attachment = Script.AttachDocumentToContact(App, contact, fileName, displayName);
Parameters
Parameter How to use it
App The ACT! application object supplied by the scripting engine.
cContact The contact receiving the document. Pass null to use the current contact.
sDocumentName The full path and filename of the document.
sDisplayName The friendly name shown in ACT!.
Returns
The new ACT! Attachment object.
CreateHistory

Creates an ACT! history for the current contact.

Syntax
Script.CreateHistory(App);
bool created = Script.CreateHistory(App, "Call", "Call Left Message", "Follow Up - Support Request", "");
Parameters
Parameter How to use it
App The ACT! application object supplied by the scripting engine.
activityType The original activity category, such as Call, Meeting, or To-do.
historyType The completed result/history type, such as Call Left Message or Call Completed.
sRegarding The history Regarding/subject text.
sDetails Additional history details. Use an empty string when none are needed.
Returns
The detailed overload returns True when the history is created. The no-parameter legacy overload is declared as Integer but does not explicitly return a number.
Example
return Script.CreateHistory(App, "Call", "Call Left Message", "Follow Up - Support Request", "");
EditHistory

Creates a history and opens it for the user to review or edit.

Syntax
bool saved = Script.EditHistory(App, "Call", "Call Completed", "Discussed renewal", "Customer requested a quote");
bool saved = Script.EditHistory(App, "Call", "Call Completed", "Discussed renewal", "Customer requested a quote", true);
Parameters
Parameter How to use it
App The ACT! application object supplied by the scripting engine.
activityType The original activity category.
historyType The completed result/history type.
sRegarding The history Regarding text.
sDetails Additional history details.
lOpen Legacy compatibility parameter. The current overload does not use this value.
Returns
True when the history is saved; False when editing is cancelled.
CreateNote

Creates a note for the current ACT! contact without opening an editor.

Syntax
bool created = Script.CreateNote(App, "Customer prefers email contact.");
Parameters
Parameter How to use it
App The ACT! application object supplied by the scripting engine.
noteText The full note text.
Returns
True when the note is created.
EditNote

Creates a note for the current ACT! contact and opens it for review or editing.

Syntax
bool saved = Script.EditNote(App, "Customer prefers email contact.");
Parameters
Parameter How to use it
App The ACT! application object supplied by the scripting engine.
noteText The starting note text.
Returns
True when the note is saved; False when editing is cancelled.

Custom Tables

CreateCustom

Creates a custom-table record without opening the editor.

Syntax
bool result = Script.CreateCustom(App, "Service Requests");
bool result = Script.CreateCustom(App, "Service Requests", "Status=New;Priority=High");
Parameters
Parameter How to use it
App The ACT! application object supplied by the scripting engine.
tableName The custom table/entity name.
defaultValues Optional starting values in the format Field=Value;Field=Value.
Returns
A Boolean result from the custom-record process.
EditCustom

Creates a custom-table record and opens the editor.

Syntax
bool result = Script.EditCustom(App, "Service Requests");
bool result = Script.EditCustom(App, "Service Requests", "Status=New;Priority=High");
Parameters
Parameter How to use it
App The ACT! application object supplied by the scripting engine.
tableName The custom table/entity name.
defaultValues Optional starting values in the format Field=Value;Field=Value.
Returns
A Boolean result from the custom-record process.
AddCustom

Core custom-record method used by CreateCustom and EditCustom.

Syntax
bool result = Script.AddCustom(App, "Service Requests", false);
bool result = Script.AddCustom(App, "Service Requests", true, "Status=New;Priority=High");
Parameters
Parameter How to use it
App The ACT! application object supplied by the scripting engine.
tableName The custom table/entity name.
edit True opens the editor; False creates the record silently.
defaultValues Optional starting values in the format Field=Value;Field=Value.
Returns
A Boolean result from the custom-record process.
Notes
For predictable edit behavior, prefer CreateCustom, EditCustom, or the four-parameter AddCustom overload.

Date and Time

GetDayOfWeek

Returns the day of the week number from a date value.

Syntax
int value = Script.GetDayOfWeek(dateValue);
Parameters
Parameter How to use it
dt1 / dateValue A DateTime value or another value that can be converted to a date.
Returns
An Integer representing the day of the week.
GetDayOfMonth

Returns the day number within the month.

Syntax
int value = Script.GetDayOfMonth(dateValue);
Parameters
Parameter How to use it
dt1 / dateValue A DateTime value or another value that can be converted to a date.
Returns
An Integer from 1 through 31.
GetDayOfYear

Returns the day number within the year.

Syntax
int value = Script.GetDayOfYear(dateValue);
Parameters
Parameter How to use it
dt1 / dateValue A DateTime value or another value that can be converted to a date.
Returns
An Integer from 1 through 366.
GetDay

Returns the day number within the month.

Syntax
int value = Script.GetDay(dateValue);
Parameters
Parameter How to use it
dt1 / dateValue A DateTime value or another value that can be converted to a date.
Returns
An Integer from 1 through 31.
GetMonth

Returns the month number from a date.

Syntax
int value = Script.GetMonth(dateValue);
Parameters
Parameter How to use it
dt1 / dateValue A DateTime value or another value that can be converted to a date.
Returns
An Integer from 1 through 12.
GetHour

Returns the hour from a date/time value.

Syntax
int value = Script.GetHour(dateValue);
Parameters
Parameter How to use it
dt1 / dateValue A DateTime value or another value that can be converted to a date.
Returns
An Integer from 0 through 23.
GetYear

Returns the four-digit year from a date.

Syntax
int value = Script.GetYear(dateValue);
Parameters
Parameter How to use it
dt1 / dateValue A DateTime value or another value that can be converted to a date.
Returns
The year as an Integer.
DateDiffDay

Returns the difference between two dates in days.

Syntax
int difference = Script.DateDiffDay(startDate, endDate);
Parameters
Parameter How to use it
dt1 / startDate The first date.
dt2 / endDate The second date.
Returns
The difference in days as an Integer.
DateDiffHour

Returns the difference between two dates in hours.

Syntax
int difference = Script.DateDiffHour(startDate, endDate);
Parameters
Parameter How to use it
dt1 / startDate The first date.
dt2 / endDate The second date.
Returns
The difference in hours as an Integer.
DateDiffMinute

Returns the difference between two dates in minutes.

Syntax
int difference = Script.DateDiffMinute(startDate, endDate);
Parameters
Parameter How to use it
dt1 / startDate The first date.
dt2 / endDate The second date.
Returns
The difference in minutes as an Integer.
DateDiffMonth

Returns the difference between two dates in months.

Syntax
int difference = Script.DateDiffMonth(startDate, endDate);
Parameters
Parameter How to use it
dt1 / startDate The first date.
dt2 / endDate The second date.
Returns
The difference in months as an Integer.
DateDiffYear

Returns the difference between two dates in years.

Syntax
int difference = Script.DateDiffYear(startDate, endDate);
Parameters
Parameter How to use it
dt1 / startDate The first date.
dt2 / endDate The second date.
Returns
The difference in years as an Integer.
CurrentHour

Returns the current hour.

Syntax
var value = Script.CurrentHour();
Returns
An Integer from 0 through 23.
CurrentMinute

Returns the current minute.

Syntax
var value = Script.CurrentMinute();
Returns
An Integer from 0 through 59.
CurrentDay

Returns today's date.

Syntax
var value = Script.CurrentDay();
Returns
A Date value for today.
CurrentDate

Returns the current date and time.

Syntax
var value = Script.CurrentDate();
Returns
A DateTime value.
CurrentDateShort

Returns the current date in short-date format.

Syntax
var value = Script.CurrentDateShort();
Returns
A formatted String.
CurrentDateLong

Returns the current date in long-date format.

Syntax
var value = Script.CurrentDateLong();
Returns
A formatted String.
CurrentMonth

Returns the current month number.

Syntax
var value = Script.CurrentMonth();
Returns
An Integer from 1 through 12.
CurrentYear

Returns the current four-digit year.

Syntax
var value = Script.CurrentYear();
Returns
The year as an Integer.
AddDays

Adds or subtracts a number of days from a date.

Syntax
DateTime result = Script.AddDays(dateValue, amount);
Parameters
Parameter How to use it
dt / dateValue The starting date/time.
val / amount The number of days to add. Use a negative number to subtract.
Returns
The calculated DateTime value.
AddHours

Adds or subtracts a number of hours from a date.

Syntax
DateTime result = Script.AddHours(dateValue, amount);
Parameters
Parameter How to use it
dt / dateValue The starting date/time.
val / amount The number of hours to add. Use a negative number to subtract.
Returns
The calculated DateTime value.
AddMonths

Adds or subtracts a number of months from a date.

Syntax
DateTime result = Script.AddMonths(dateValue, amount);
Parameters
Parameter How to use it
dt / dateValue The starting date/time.
val / amount The number of months to add. Use a negative number to subtract.
Returns
The calculated DateTime value.
AddMinutes

Adds or subtracts a number of minutes from a date.

Syntax
DateTime result = Script.AddMinutes(dateValue, amount);
Parameters
Parameter How to use it
dt / dateValue The starting date/time.
val / amount The number of minutes to add. Use a negative number to subtract.
Returns
The calculated DateTime value.
AddYears

Adds or subtracts a number of years from a date.

Syntax
DateTime result = Script.AddYears(dateValue, amount);
Parameters
Parameter How to use it
dt / dateValue The starting date/time.
val / amount The number of years to add. Use a negative number to subtract.
Returns
The calculated DateTime value.

Math

Ceiling

Rounds a number upward to the next whole number.

Syntax
decimal result = Script.Ceiling(value);
Parameters
Parameter How to use it
value / value1 A number or value that can be converted to a number.
Returns
A Decimal whole-number value.
Floor

Rounds a number downward to the previous whole number.

Syntax
decimal result = Script.Floor(value);
Parameters
Parameter How to use it
value / value1 A number or value that can be converted to a number.
Returns
A Decimal whole-number value.
Round

Rounds a number to the nearest whole number or to a specified number of decimal places.

Syntax
double result = Script.Round(value);
double result = Script.Round(value, precision);
Parameters
Parameter How to use it
value / value1 A number or value that can be converted to a number.
precision Optional number of decimal places.
Returns
The rounded value as a Double.
Absolute

Returns the positive magnitude of a number.

Syntax
double result = Script.Absolute(value);
Parameters
Parameter How to use it
value / value1 A number or value that can be converted to a number.
Returns
The absolute value as a Double.
Maximum

Returns the larger of two numbers.

Syntax
double result = Script.Maximum(value1, value2);
Parameters
Parameter How to use it
value / value1 A number or value that can be converted to a number.
value2 The second number to compare.
Returns
The larger value as a Double.
Minimum

Returns the smaller of two numbers.

Syntax
double result = Script.Minimum(value1, value2);
Parameters
Parameter How to use it
value / value1 A number or value that can be converted to a number.
value2 The second number to compare.
Returns
The smaller value as a Double.

Conversion and Text

ConvertToString

Converts a value to text.

Syntax
var result = Script.ConvertToString(value);
Parameters
Parameter How to use it
value / value1 The value to convert or the first value to join.
Returns
The converted String.
ConvertToDate

Converts a value to a DateTime.

Syntax
var result = Script.ConvertToDate(value);
Parameters
Parameter How to use it
value / value1 The value to convert or the first value to join.
Returns
The converted DateTime value.
ConvertToNumber

Converts a value to a whole number.

Syntax
var result = Script.ConvertToNumber(value);
Parameters
Parameter How to use it
value / value1 The value to convert or the first value to join.
Returns
The converted Integer.
ConvertToDecimal

Converts a value to a decimal number.

Syntax
var result = Script.ConvertToDecimal(value);
Parameters
Parameter How to use it
value / value1 The value to convert or the first value to join.
Returns
The converted Decimal.
ToProper

Converts text to proper/title case.

Syntax
var result = Script.ToProper(value);
Parameters
Parameter How to use it
value / value1 The value to convert or the first value to join.
Returns
The converted String.
Join

Combines two values into one text value.

Syntax
string result = Script.Join(value1, value2);
Parameters
Parameter How to use it
value / value1 The value to convert or the first value to join.
value2 The second value to append.
Returns
A String containing both values.

Automation: scripts that run without the ACT! desktop

Automations run from the scheduler or server process, often when no user is working in ACT!. They can read and update the ACT! database through HostFramework, process specific contacts or opportunities, create activities and custom records, merge data, and send email.

No ACT! user interface is available. An automation must never call App, HostApplication, CurrentView, ACT! dialog managers, Windows Forms controls, or methods that open an ACT! screen. There is no “Current Contact” or “Current Opportunity” selected by a user. The automation must use the specific contact, company, group, or opportunity object passed into the code.
No matching automation methods were found.

Server-safe Automation Methods

CreateActivityServer-safe

Creates an ACT! activity for a specific contact without requiring the ACT! desktop user interface.

Syntax
Automation.CreateActivity(HostFramework, contact, "Call");
Automation.CreateActivity(HostFramework, contact, "Call", "High");
Automation.CreateActivity(HostFramework, contact, "Call", "High", "Follow up", "Called from automation", "Jim Durkin");
Automation.CreateActivity(HostFramework, contact, "Call", "Follow up", DateTime.Now.AddDays(1), 15);
Parameters
Parameter How to use it
HostFramework The logged-on ACT! framework/database object supplied to the automation.
contact The specific ACT! Contact that receives the activity.
type The ACT! activity type, such as Call, Meeting, or To-do.
priority The activity priority text.
regarding The activity Regarding text.
notes Notes stored with the activity.
scheduledFor The ACT! user the activity should be scheduled for.
startDate The activity start date and time.
length The activity duration in minutes.
Returns
A Boolean or legacy Integer result depending on the overload. Use the method primarily for its activity-creation action.
CreateCustomServer-safe

Creates a record in an ACT! custom table and optionally associates contacts, companies, groups, or opportunities.

Syntax
var record = Automation.CreateCustom(HostFramework, contact, "Service Requests");
var record = Automation.CreateCustom(HostFramework, contact, true, "Service Requests");
var record = Automation.CreateCustom(HostFramework, contact, company, group, opportunity, true, true, "Service Requests");
Parameters
Parameter How to use it
HostFramework The ACT! framework/database object.
contact The contact associated with the new custom record.
company An optional company to associate.
group An optional group to associate.
opportunity An optional opportunity to associate.
attachcompany True attaches the available company.
attachcontacts True attaches the available contact.
tableName The custom table/entity name.
Returns
The newly created CustomSubEntityDurkin record, or Nothing/null if creation fails.
MergeStringUsingBracketsServer-safe

Replaces ACT! merge fields inside a text string using configurable left and right brackets.

Syntax
string result = Automation.MergeStringUsingBrackets(HostFramework, "Hello <<Contact: First Name>>", "<<", ">>", contact, "");
Parameters
Parameter How to use it
HostFramework The ACT! framework/database object.
RawTextString The text containing merge tokens.
LeftBracket The characters that begin a token, commonly <<.
RightBracket The characters that end a token, commonly >>.
contact The contact whose values are merged.
defaultstring Text used when a requested value is blank or unavailable.
Returns
A String containing the merged result.
MergeHtmlDocumentServer-safe

Merges ACT! data into HTML content for a contact and campaign.

Syntax
string html = Automation.MergeHtmlDocument(HostFramework, contact, printPreferences, htmlText, campaignId);
HtmlDocument doc = Automation.MergeHtmlDocument(HostFramework, contact, printPreferences, htmlDocument, campaignId, row);
Parameters
Parameter How to use it
HostFramework The ACT! framework/database object.
cContact The contact used for merge values.
PreferencesPrint The document-engine preference data.
HtmlString / HtmlDoc The HTML text or HTML document to merge.
CampaignID The campaign identifier used by the merge process.
cRow An optional DataRow containing automation settings.
Returns
The merged HTML as a String or HtmlDocument, depending on the overload.
GetHtmlDocumentServer-safe

Converts an HTML string into a Windows Forms HtmlDocument object.

Syntax
HtmlDocument doc = Automation.GetHtmlDocument(html);
Parameters
Parameter How to use it
html The complete HTML string to load.
Returns
A System.Windows.Forms.HtmlDocument object.
Notes
This helper creates an HTML document object. It does not display an ACT! window.
SendEmailviaSMTPServer-safe

Sends an email directly through an SMTP server. This is the preferred email method for unattended server automation.

Syntax
bool sent = Automation.SendEmailviaSMTP(logfile, toList, ccList, bccList, subject, body, attachments, images, fromAddress, smtpServer, smtpPort, userName, password, testMode, testAddress, enableSsl);
Parameters
Parameter How to use it
logactionfile The automation log used to record the send result.
toList / ccList / bccList ArrayList collections of recipient addresses.
sEmailSubject The email subject.
sEmailBody The email body.
sAttachments Attachment paths used by the automation.
strImages Images used by the HTML message.
EmailFrom The sender address.
SMTPClient The SMTP server name.
SMTPPort The SMTP port.
SMTPUserName / SMTPPassword Credentials used by the SMTP server.
TestMode True redirects the message to a test address.
TestModeEmailTo The address used when TestMode is enabled.
EnableSSL True enables SSL/TLS for the SMTP connection.
Returns
True when the SMTP operation succeeds; otherwise False.

Automation Engine and Desktop-specific Methods

SendEmailviaOutLookDesktop only

Creates or sends email through Microsoft Outlook.

Syntax
bool sent = Automation.SendEmailviaOutLook(logfile, outlook, toList, ccList, bccList, subject, body, attachments, images, uiAvailable, preview);
Parameters
Parameter How to use it
logactionfile The automation log.
oOutLook A running Outlook Application COM object.
toList / ccList / bccList Recipient address collections.
sEmailSubject The email subject.
sEmailBody The email body.
sAttachments Attachment paths.
strImages Images used in the message.
UiAvaiable Whether a desktop user interface is available.
lPreview True previews the email instead of sending immediately.
Returns
True when the Outlook operation succeeds; otherwise False.
Notes
Do not use this method for true server-only automation unless Outlook is installed, configured, and running in an interactive Windows session. SMTP is safer for unattended execution.
OnScheduleAutomation engine

Runs a saved automation by its automation ID.

Syntax
bool result = Automation.OnSchedule(HostFramework, automationId, false);
Parameters
Parameter How to use it
HostFramework The logged-on ACT! framework/database object.
AutoID The ID of the saved automation to execute.
lPreview True runs in preview mode where supported; False performs the configured action.
Returns
True or False according to the scheduled automation result.
Notes
This is normally called by the Impact scheduler rather than from an end-user custom automation script.
ActionCustomAutomation engine

Compiles and runs the custom Script_Code stored in an automation configuration row for a contact.

Syntax
Automation.ActionCustom(HostFramework, automationRow, contact, logfile);
Parameters
Parameter How to use it
HostFramework The ACT! framework/database object.
nRow The DataRow containing the saved automation configuration.
cContact The contact being processed.
logfile The automation log file.
Returns
A legacy Boolean result. The important result is the execution of the saved custom code.
Notes
Automation engine method; most end users should not call it directly.
ActionOpportunityAutomation engine

Creates an opportunity from the values stored in an automation configuration row.

Syntax
Automation.ActionOpportunity(HostFramework, automationRow, contact, logfile);
Parameters
Parameter How to use it
HostFramework The ACT! framework/database object.
nRow The automation configuration row containing opportunity name, process, stage, product, quantity, cost, price, and discount.
cContact The contact attached to the new opportunity.
logfile The automation log file.
Returns
A legacy Boolean result. The configured opportunity is created and updated.
Notes
Automation engine method; use CreateOpportunity-style configuration in the automation designer whenever possible.
ActionActivityAutomation engine

Creates an activity using either an automation configuration row or a full set of activity settings.

Syntax
Automation.ActionActivity(HostFramework, automationRow, contact, logfile);
Automation.ActionActivity(HostFramework, activityType, extended, regarding, anchorField, anchorTime, anchorOffset, anchorMinutes, anchorOffsetType, priority, notes, scheduledFor, contact, logfile);
Parameters
Parameter How to use it
HostFramework The ACT! framework/database object.
nRow A saved automation configuration row.
Activity_Type The ACT! activity type.
Activity_Extended Whether the extended activity configuration is used.
Activity_Regarding The activity Regarding text.
Activity_AnchorField / Activity_AnchorTime The date field and time used as the scheduling anchor.
Activity_AnchorOffset / Activity_AnchorMinutes / Activity_AnchorOffsetType Values used to calculate the scheduled date and time.
Activity_Priority The activity priority.
Activity_Notes Activity notes.
Activity_ScheduledFor The ACT! user assigned to the activity.
contact The contact attached to the activity.
logfile The optional automation log.
Returns
True or False according to the activity action.
Notes
Automation engine method. The simpler CreateActivity overloads are easier for custom code.
ActionDocumentAutomation engine

Creates a document for a contact using the document settings stored in an automation row.

Syntax
Automation.ActionDocument(HostFramework, automationRow, contact, logfile);
Parameters
Parameter How to use it
HostFramework The ACT! framework/database object.
nRow The saved document automation settings.
cContact The contact used for the document merge.
logfile The automation log file.
Returns
True or False according to the document action.
Notes
Automation engine method.
ActionEmail / ActionEmailHTMLAutomation engine

Creates or sends an automation email using the settings stored in a DataRow.

Syntax
Automation.ActionEmail(HostFramework, outlook, word, automationRow, contact, logfile, preview);
Automation.ActionEmailHTML(HostFramework, outlook, word, automationRow, contactRow, contact, logfile, printPreferences, preview);
Parameters
Parameter How to use it
HostFramework The ACT! framework/database object.
oOutLook / oWord Microsoft Office COM application objects used by desktop email generation.
nRow The saved email automation configuration.
contactRow A DataRow containing contact values for the HTML action.
cContact The contact receiving the email.
logfile The automation log.
printPreferences Document merge preferences.
lPreview True previews where supported; False performs the send action.
Returns
True or False according to the email action.
Notes
These are automation engine methods. For unattended server code, prefer SendEmailviaSMTP rather than methods that depend on Outlook or Word.
OnActStartup / OnActShutdownDesktop only

Legacy ACT! lifecycle handlers intended to run when the ACT! desktop application starts or shuts down.

Syntax
Automation.OnActStartup(HostApplication, HostFramework, Preferences);
Automation.OnActShutdown(HostApplication, HostFramework, Preferences);
Parameters
Parameter How to use it
HostApplication The ACT! desktop application object.
HostFramework The ACT! framework/database object.
Preferences Impact preference settings.
Returns
A legacy Object/Nothing result.
Notes
These methods require the ACT! desktop environment and are not available to server-only scheduled automation.
Impact Video
Impact AI Assistant
Hi! I’m the Impact AI Assistant.

Tell me what you’d like to do in ACT!, and I’ll show you how Impact Studio can help.
Mockup Form