1. Home
  2. /
  3. Docs
  4. /
  5. Articles Report Writer
  6. /
  7. Sage 50 Functions

Sage 50 Functions

Sage 50 functions are available throughout the Articles report script editor. They decode numeric codes stored in the Sage 50 database into human-readable descriptions, and provide utilities specific to Sage 50 data structures. These functions are only relevant when Articles is connected to a Sage 50 data source.

The codes shown here represent a shortened subset of the full list.

This is only a partial code list, condensed for clarity and brevity.

AttachmentBundle_ItemType

Returns the description for an attachment bundle item type code.

AttachmentBundle_ItemType(ItemType: Variant): String
CodeDescription
0Customer
1Vendor
2Employee
3Inventory Item
Result := AttachmentBundle_ItemType([Attachments.ItemType]);
// 0 returns 'Customer', 2 returns 'Employee'

AuditTrail_ActionCode

Returns the description for an audit trail action code.

AuditTrail_ActionCode(ActionCode: Variant): String
CodeDescription
0Delete
1Add
2Change
3Void
Result := AuditTrail_ActionCode([AuditTrail.ActionCode]);
// 1 returns 'Add', 3 returns 'Void'

// Flag deletions in an audit report
if AuditTrail_ActionCode([AuditTrail.ActionCode]) = 'Delete' then
  Result := '** DELETED **';

CashFlow_TransactionType

Returns the description for a cash flow transaction type code.

CashFlow_TransactionType(TransactionType: Variant): String
CodeDescription
1Invoice
2Receipt
12Payroll
13Payment
Result := CashFlow_TransactionType([CashFlow.TransactionType]);
// 1 returns 'Invoice', 13 returns 'Payment'

Chart_AccountType

Returns the full description for a chart of accounts type code.

Chart_AccountType(AccountType: Variant): String
CodeDescription
0Cash
1Accounts Receivable
2Inventory
10Accounts Payable
21Income
23Cost of Sales
24Expenses
Result := Chart_AccountType([Chart.AccountType]);
// 21 returns 'Income', 24 returns 'Expenses'

Chart_AccountTypeShort

Returns the abbreviated description for a chart of accounts type code. Use this where space is limited.

Chart_AccountTypeShort(AccountType: Variant): String
CodeDescription
0Cash
1AR
2Inventory
10AP
21Income
23Cost of Sales
24Expenses
Result := Chart_AccountTypeShort([Chart.AccountType]);
// 1 returns 'AR', 10 returns 'AP'

CompanyInformation_CompanyType

Returns the description for a company type code.

CompanyInformation_CompanyType(CompanyType: Variant): String
CodeDescription
0Corporation
1S Corporation
2Partnership
3Sole Proprietorship
Result := CompanyInformation_CompanyType([Company.CompanyType]);
// 0 returns 'Corporation', 3 returns 'Sole Proprietorship'

Customers_CreditStatus

Returns the description for a customer credit status code.

Customers_CreditStatus(CreditStatus: Variant): String
CodeDescription
0No Credit Limit
1Notify Over Limit
2Always Notify
3Hold Over Limit
4Always Hold
Result := Customers_CreditStatus([Customer.CreditStatus]);
// 3 returns 'Hold Over Limit', 4 returns 'Always Hold'

// Flag customers on hold
if [Customer.CreditStatus] >= 3 then
  Result := '** CREDIT HOLD: ' + Customers_CreditStatus([Customer.CreditStatus]) + ' **';

Employees_EthnicOrigin

Returns the description for an employee ethnic origin code.

Employees_EthnicOrigin(EthnicOrigin: Variant): String
CodeDescription
1American Indian / Alaska Native
2Asian
3Black / African American
4Hispanic / Latino
Result := Employees_EthnicOrigin([Employee.EthnicOrigin]);

Employees_FederalFilingStatus

Returns the description for an employee federal filing status code.

Employees_FederalFilingStatus(FederalFilingStatus: Variant): String
Result := Employees_FederalFilingStatus([Employee.FederalFilingStatus]);
// Returns values such as 'Single', 'Married', 'Head of Household'

Employees_I9VerificationStatus

Returns the description for an employee I-9 verification status code.

Employees_I9VerificationStatus(I9VerificationStatus: Variant): String
CodeDescription
0Not Specified
1Yes
2No
3Pending
Result := Employees_I9VerificationStatus([Employee.I9VerificationStatus]);
// 3 returns 'Pending'

Employees_MaritalStatus

Returns the description for an employee marital status code.

Employees_MaritalStatus(MaritalStatus: Variant): String
CodeDescription
0Not Specified
1Married
2Single
3Divorced
4Widowed
5Other
Result := Employees_MaritalStatus([Employee.MaritalStatus]);
// 1 returns 'Married', 2 returns 'Single'

Employees_PayFrequency

Returns the description for an employee pay frequency code.

Employees_PayFrequency(PayFrequency: Variant): String
CodeDescription
0Weekly
1Bi-Weekly
2Semi-Monthly
3Monthly
6Annually
Result := Employees_PayFrequency([Employee.PayFrequency]);
// 1 returns 'Bi-Weekly', 3 returns 'Monthly'

Employees_PayMethod

Returns the description for an employee pay method code.

Employees_PayMethod(PayMethod: Variant): String
CodeDescription
-1 / 0Salary
1Hourly per pay period
2Hourly time ticket
3Hourly E-ticket
Result := Employees_PayMethod([Employee.PayMethod]);
// 1 returns 'Hourly per pay period'

Eventlog_EventCategory

Returns the description for an event log category code.

Eventlog_EventCategory(EventCategory: Variant): String
CodeDescription
0Activity
1Quote Sent
4Invoice Sent
13Paycheck
Result := Eventlog_EventCategory([EventLog.EventCategory]);

Eventlog_EventType

Returns the description for an event log type code.

Eventlog_EventType(EventType: Variant): String
CodeDescription
1Customer / Prospect
2Employee / Sales Rep
3Vendor
4Todo
Result := Eventlog_EventType([EventLog.EventType]);
// 1 returns 'Customer / Prospect', 4 returns 'Todo'

GetPeachtreeFlavor

Returns the Sage 50 product edition (First, Pro, Complete, etc.) based on the company data folder version file.

GetPeachtreeFlavor(DataLocation: String): String
ParameterTypeDescription
DataLocationStringThe path to the Sage 50 company data folder
Result := GetPeachtreeFlavor([Company.DataPath]);
// Returns: 'Complete', 'Pro', 'First', etc.

// Show edition in a report header
Result := 'Sage 50 ' + GetPeachtreeFlavor([Company.DataPath]);

InventoryCost_Code

Returns the description for an inventory cost code.

InventoryCost_Code(Code: Variant): String
CodeDescription
10Received
20Returned Sale
30Returned Purchase
40Sale
50Balance
Result := InventoryCost_Code([InventoryCost.Code]);
// 40 returns 'Sale', 10 returns 'Received'

InventoryCost_RecordCode

Returns the description for an inventory cost record code.

InventoryCost_RecordCode(RecordCode: Variant): String
CodeDescription
1Receipt
3Sale
7Inventory Adjustment
15Balance
Result := InventoryCost_RecordCode([InventoryCost.RecordCode]);
// 1 returns 'Receipt', 7 returns 'Inventory Adjustment'

JrnlHdr_JournalEx

Returns the extended journal description for a journal code.

JrnlHdr_JournalEx(JournalEx: Variant): String
CodeDescription
1General
3Cash Receipt
8Sales Invoice
Result := JrnlHdr_JournalEx([JournalHeader.JournalEx]);

JrnlHdr_JrnlTypeEx

Returns the extended journal type description for a journal type code.

JrnlHdr_JrnlTypeEx(JrnlTypeEx: Variant): String
CodeDescription
1Write Check
2Customer Credit Memo
3Vendor Credit Memo
Result := JrnlHdr_JrnlTypeEx([JournalHeader.JrnlTypeEx]);
// 1 returns 'Write Check'

Jrnlhdr_PayMethod

Returns the payroll pay method or frequency description for a journal header pay method code.

Jrnlhdr_PayMethod(PayMethod: Variant): String
Result := Jrnlhdr_PayMethod([JournalHeader.PayMethod]);
// Returns salary or time ticket variant descriptions

JrnlRow_TrxType

Returns the description for a journal row transaction type code.

JrnlRow_TrxType(TrxType: Variant): String
CodeDescription
0Normal
1COGS
2Inventory Charge
5Sales Tax
6Freight
Result := JrnlRow_TrxType([JournalRow.TrxType]);
// 5 returns 'Sales Tax', 6 returns 'Freight'

JrnlSNo_TransactionClass

Returns the description for a journal transaction class code.

JrnlSNo_TransactionClass(TransactionClass: Variant): String
CodeDescription
0Reserved
1Origination
2Intermediate
3Sale
4Return
5Adjustment
Result := JrnlSNo_TransactionClass([Journal.TransactionClass]);
// 3 returns 'Sale', 4 returns 'Return'

JournalDescription

Returns the full journal description for a journal code.

JournalDescription(JournalCode: Variant): String
CodeDescription
0General Journal
1Cash Receipts
2Cash Disbursements
3Sales Journal
4Purchases Journal
5Payroll Journal
Result := JournalDescription([Journal.JournalCode]);
// 0 returns 'General Journal', 1 returns 'Cash Receipts'

JournalDescriptionShort

Returns the abbreviated journal code description. Use this where space is limited.

JournalDescriptionShort(JournalCode: Variant): String
CodeDescription
0GL
1CRJ
2CDJ
3SJ
4PJ
5PYR
Result := JournalDescriptionShort([Journal.JournalCode]);
// 0 returns 'GL', 1 returns 'CRJ'

LineItems_CostingMethod

Returns the description for an inventory costing method code.

LineItems_CostingMethod(CostingMethod: Variant): String
CodeDescription
-1None
0Average
1FIFO
2LIFO
3Specific
Result := LineItems_CostingMethod([Item.CostingMethod]);
// 1 returns 'FIFO', 2 returns 'LIFO'

LineItem_ItemClass

Returns the description for a line item class code.

LineItem_ItemClass(ItemClass: Variant): String
CodeDescription
0Non Stock
1Stock
2Description
3Assembly
4Service
5Labor
Result := LineItem_ItemClass([LineItem.ItemClass]);
// 1 returns 'Stock', 4 returns 'Service'

LineItem_WarrantyPeriod

Returns the description for a warranty period unit code.

LineItem_WarrantyPeriod(WarrantyPeriod: Variant): String
CodeDescription
0Days
1Months
2Years
Result := IntToStr([LineItem.WarrantyLength]) + ' ' +
          LineItem_WarrantyPeriod([LineItem.WarrantyPeriod]);
// Returns: '12 Months' or '2 Years'

NumberOfDistributions

Returns the number of distributions for a journal entry.

NumberOfDistributions(ConnectionDef: String; PostOrder: Integer): Integer
ParameterTypeDescription
ConnectionDefStringThe connection definition name
PostOrderIntegerThe journal post order number
var count := NumberOfDistributions([ConnectionDef], [Journal.PostOrder]);
Result := IntToStr(count) + ' ' + Pluralize(count, 'distribution', 'distributions');

SagePeriodEndDate

Returns the end date for a specified Sage 50 accounting period.

SagePeriodEndDate(ConnectionDef: String; PeriodNumber: Integer): TDateTime
ParameterTypeDescription
ConnectionDefStringThe connection definition name
PeriodNumberIntegerThe accounting period number (1-12)
Result := DateToStr(SagePeriodEndDate([ConnectionDef], [Param.Period]));
// Returns the last date of the specified period

// Show the period range
Result := DateToStr(SagePeriodStartDate([ConnectionDef], [Param.Period])) +
          ' to ' +
          DateToStr(SagePeriodEndDate([ConnectionDef], [Param.Period]));

SagePeriodStartDate

Returns the start date for a specified Sage 50 accounting period.

SagePeriodStartDate(ConnectionDef: String; PeriodNumber: Integer): TDateTime
ParameterTypeDescription
ConnectionDefStringThe connection definition name
PeriodNumberIntegerThe accounting period number (1-12)
Result := DateToStr(SagePeriodStartDate([ConnectionDef], [Param.Period]));
// Returns the first date of the specified period

// Use to set a date range for the period
var startDate := SagePeriodStartDate([ConnectionDef], [Param.Period]);
var endDate   := SagePeriodEndDate([ConnectionDef], [Param.Period]);
Result := FormatDateRange(startDate, endDate);

Ticket_BillingStatus

Returns the description for a ticket billing status code.

Ticket_BillingStatus(BillingStatus: Variant): String
CodeDescription
1Billable
2Non-Billable
3No Charge
4Hold
Result := Ticket_BillingStatus([Ticket.BillingStatus]);
// 1 returns 'Billable', 4 returns 'Hold'

Ticket_BillingType

Returns the description for a ticket billing type code.

Ticket_BillingType(BillingType: Variant): String
CodeDescription
0Admin
1Employee Rate
2Activity Rate
3Override
4Flat Fee
Result := Ticket_BillingType([Ticket.BillingType]);
// 1 returns 'Employee Rate', 4 returns 'Flat Fee'

Ticket_CustJobAdmin

Returns the description for a ticket class code indicating whether the ticket is for a customer, job, or administrative purpose.

Ticket_CustJobAdmin(CustJobAdmin: Variant): String
CodeDescription
1Customer
2Job
3Administrative
Result := Ticket_CustJobAdmin([Ticket.CustJobAdmin]);
// 1 returns 'Customer', 2 returns 'Job'

Ticket_ItemClass

Returns the description for a ticket item class code.

Ticket_ItemClass(ItemClass: Variant): String
CodeDescription
0Time Ticket
1Expense Ticket
Result := Ticket_ItemClass([Ticket.ItemClass]);
// 0 returns 'Time Ticket', 1 returns 'Expense Ticket'

UPSShipment_ServiceLevel

Returns the description for a UPS shipment service level code.

UPSShipment_ServiceLevel(ServiceLevel: Variant): String
CodeDescription
1Next Day Air
2Second Day Air
3Ground
Result := UPSShipment_ServiceLevel([Shipment.ServiceLevel]);
// 1 returns 'Next Day Air', 3 returns 'Ground'

VendorInsurance_InsuranceType

Returns the description for a vendor insurance type code.

VendorInsurance_InsuranceType(InsuranceType: Variant): String
CodeDescription
1Workers Comp
2General Liability
3Umbrella
4Automobile
Result := VendorInsurance_InsuranceType([VendorInsurance.InsuranceType]);
// 1 returns 'Workers Comp', 2 returns 'General Liability'

Vendors_Type1099

Returns the description for a vendor 1099 type code.

Vendors_Type1099(Type1099: Variant): String
CodeDescription
0None
1Interest
2Misc
3Rent
4Dividends
Result := Vendors_Type1099([Vendor.Type1099]);
// 2 returns 'Misc', 3 returns 'Rent'

// Flag vendors that require a 1099
if [Vendor.Type1099] > 0 then
  Result := '1099 Required: ' + Vendors_Type1099([Vendor.Type1099]);