Show / Hide Table of Contents

Class Function

Base class for any scripting function

Inheritance
object
Function
PayrollFunction
ReportFunction
Implements
IDisposable
Inherited Members
object.GetType()
object.MemberwiseClone()
object.ToString()
object.Equals(object)
object.Equals(object, object)
object.ReferenceEquals(object, object)
object.GetHashCode()
Namespace: PayrollEngine.Client.Scripting.Function
Assembly: PayrollEngine.Client.Scripting.dll
Syntax
public abstract class Function : IDisposable

Constructors

View Source

Function(object)

New function instance

Declaration
protected Function(object runtime)
Parameters
Type Name Description
object runtime

The function runtime

View Source

Function(string)

New function instance without runtime (scripting development)

Declaration
protected Function(string sourceFileName)
Parameters
Type Name Description
string sourceFileName

The name of the source file

Remarks

Use GetSourceFileName(string) in your constructor for the source file name

Properties

View Source

AdminUser

Tests whether the current user has administrator-level access

Declaration
public bool AdminUser { get; }
Property Value
Type Description
bool
View Source

Runtime

The function runtime

Declaration
protected dynamic Runtime { get; }
Property Value
Type Description
dynamic
View Source

SelfServiceUser

Tests whether the current user is an employee acting in self-service context

Declaration
[ActionProperty("Test for self service user", null)]
public bool SelfServiceUser { get; }
Property Value
Type Description
bool
View Source

SourceFileName

The name of the source file (scripting development)

Declaration
public string SourceFileName { get; }
Property Value
Type Description
string

The name of the source file

View Source

TenantId

The tenant id

Declaration
public int TenantId { get; }
Property Value
Type Description
int
View Source

TenantIdentifier

The tenant identifier

Declaration
public string TenantIdentifier { get; }
Property Value
Type Description
string
View Source

UserCulture

The user culture

Declaration
[ActionProperty("User culture", null)]
public string UserCulture { get; }
Property Value
Type Description
string
View Source

UserId

The user id

Declaration
public int UserId { get; }
Property Value
Type Description
int
View Source

UserIdentifier

The user identifier

Declaration
[ActionProperty("User identifier", null)]
public string UserIdentifier { get; }
Property Value
Type Description
string
View Source

UserType

The user type

Declaration
public UserType UserType { get; }
Property Value
Type Description
UserType

Methods

View Source

AddTask(string, string, DateTime, string, Dictionary<string, object>)

Creates a scheduled task that is visible in the PayrollEngine task list after the function completes

Declaration
public void AddTask(string name, string instruction, DateTime scheduleDate, string category = null, Dictionary<string, object> attributes = null)
Parameters
Type Name Description
string name

The task name, displayed in the task list

string instruction

Free-text instructions for the user who will process the task

DateTime scheduleDate

The date on which the task is due

string category

Optional grouping category for filtering tasks

Dictionary<string, object> attributes

Optional key/value metadata attached to the task

Remarks

Tasks are a lightweight way to trigger manual follow-up work from within a function. They are written to the task store when the function exits and do not affect the payrun result. Common uses: document request after a case change, approval reminder after a payrun, compliance alert when a threshold is exceeded.

View Source

ChangeValueType<T>(object, T, IFormatProvider)

Change value type

Declaration
public T ChangeValueType<T>(object value, T defaultValue = default, IFormatProvider provider = null)
Parameters
Type Name Description
object value

Value to change

T defaultValue

Default value

IFormatProvider provider

Format provider (default InvariantCulture)

Returns
Type Description
T
Type Parameters
Name Description
T
Remarks

Handles JsonElement values, null inputs, and Nullable<T> target types, which ChangeType(object, Type) does not support natively. Uses InvariantCulture by default.

View Source

Dispose()

Dispose the function

Declaration
public virtual void Dispose()
View Source

GetCalendarDayCount(DateTime, DateTime, string)

Counts calendar days in the given period using the tenant calendar

Declaration
public int GetCalendarDayCount(DateTime start, DateTime end, string culture = null)
Parameters
Type Name Description
DateTime start

The period start date

DateTime end

The period end date

string culture

The calendar culture (default: tenant culture)

Returns
Type Description
int

Number of calendar days in the period

View Source

GetCalendarDayCount(string, DateTime, DateTime, string)

Counts calendar days in the given period using a named calendar

Declaration
public int GetCalendarDayCount(string calendarName, DateTime start, DateTime end, string culture = null)
Parameters
Type Name Description
string calendarName

The calendar name

DateTime start

The period start date

DateTime end

The period end date

string culture

The calendar culture (default: tenant culture)

Returns
Type Description
int

Number of calendar days in the period

View Source

GetCalendarPeriod(DateTime?, int, int, int)

Gets the calendar period

Declaration
public DatePeriod GetCalendarPeriod(DateTime? moment = null, int divisionId = 0, int employeeId = 0, int offset = 0)
Parameters
Type Name Description
DateTime? moment

Moment within the period (default: today)

int divisionId

The division id, use 0 to ignore the division culture

int employeeId

The employee id, use 0 to ignore the employee culture

int offset

The period offset (default: 0/current)

Returns
Type Description
DatePeriod

The period start and end date

View Source

GetCalendarPeriod(string, DateTime?, int, string)

Gets the calendar period

Declaration
public DatePeriod GetCalendarPeriod(string calendarName, DateTime? moment = null, int offset = 0, string culture = null)
Parameters
Type Name Description
string calendarName

The calendar name

DateTime? moment

Moment within the period (default: today)

int offset

The period offset (default: 0/current)

string culture

The calendar culture (default: tenant culture)

Returns
Type Description
DatePeriod

The period start and end date

View Source

GetDerivedCalendar(int, int)

Returns the most specific calendar name available in the context

Declaration
public string GetDerivedCalendar(int divisionId = 0, int employeeId = 0)
Parameters
Type Name Description
int divisionId

The division id; pass 0 to skip the division level

int employeeId

The employee id; pass 0 to skip the employee level

Returns
Type Description
string

The most derived calendar name

Remarks

Resolution order: employee calendar → division calendar → tenant calendar (fallback).

View Source

GetDerivedCulture(int, int)

Returns the most specific culture name available in the context

Declaration
public string GetDerivedCulture(int divisionId = 0, int employeeId = 0)
Parameters
Type Name Description
int divisionId

The division id; pass 0 to skip the division level

int employeeId

The employee id; pass 0 to skip the employee level

Returns
Type Description
string

The most derived culture name

Remarks

Resolution order: employee culture → division culture → tenant culture (fallback).

View Source

GetNextWorkDay(string, DateTime?)

Get next working day

Declaration
public DateTime GetNextWorkDay(string calendarName, DateTime? moment = null)
Parameters
Type Name Description
string calendarName

The calendar name

DateTime? moment

The start moment (default: today)

Returns
Type Description
DateTime
View Source

GetNextWorkDays(string, DateTime?, int)

Get next working days

Declaration
public List<DateTime> GetNextWorkDays(string calendarName, DateTime? moment = null, int count = 1)
Parameters
Type Name Description
string calendarName

The calendar name

DateTime? moment

The start moment (default: today, not included in results)

int count

The number of days (default: 1)

Returns
Type Description
List<DateTime>
View Source

GetPreviousWorkDay(string, DateTime?)

Get previous working day

Declaration
public DateTime GetPreviousWorkDay(string calendarName, DateTime? moment = null)
Parameters
Type Name Description
string calendarName

The calendar name

DateTime? moment

The start moment (default: today)

Returns
Type Description
DateTime
View Source

GetPreviousWorkDays(string, DateTime?, int)

Get previous working days

Declaration
public List<DateTime> GetPreviousWorkDays(string calendarName, DateTime? moment = null, int count = 1)
Parameters
Type Name Description
string calendarName

The calendar name

DateTime? moment

The start moment (default: today, not included in results)

int count

The number of days (default: 1)

Returns
Type Description
List<DateTime>
View Source

GetSourceFileName(string)

Initialize the source file path (scripting development)

Declaration
protected static string GetSourceFileName(string sourceFilePath = "")
Parameters
Type Name Description
string sourceFilePath

The source file path (do not provide a value)

Returns
Type Description
string

Source code file name

View Source

GetTenantAttribute(string)

Get tenant attribute value

Declaration
public object GetTenantAttribute(string attributeName)
Parameters
Type Name Description
string attributeName
Returns
Type Description
object
View Source

GetTenantAttribute<T>(string, T)

Get tenant attribute typed value

Declaration
public T GetTenantAttribute<T>(string attributeName, T defaultValue = default)
Parameters
Type Name Description
string attributeName
T defaultValue
Returns
Type Description
T
Type Parameters
Name Description
T
View Source

GetUserAttribute(string)

Get user attribute value

Declaration
public object GetUserAttribute(string attributeName)
Parameters
Type Name Description
string attributeName
Returns
Type Description
object
View Source

GetUserAttribute<T>(string, T)

Get user attribute typed value

Declaration
public T GetUserAttribute<T>(string attributeName, T defaultValue = default)
Parameters
Type Name Description
string attributeName
T defaultValue
Returns
Type Description
T
Type Parameters
Name Description
T
View Source

InvokeWebhook<T>(string, object)

Sends a synchronous webhook request to an external endpoint and returns the deserialized response

Declaration
public T InvokeWebhook<T>(string requestOperation, object requestMessage = null)
Parameters
Type Name Description
string requestOperation

The operation name that identifies the target webhook endpoint

object requestMessage

Optional request payload; serialized to JSON before sending

Returns
Type Description
T

The deserialized response, or default(T) when the response body is empty

Type Parameters
Name Description
T

The expected response type; the JSON response body is deserialized into this type

Remarks

Webhooks are configured on the tenant and mapped to operation names. The call is synchronous — the function waits for the HTTP response before continuing. Use this to integrate external systems (e.g. send a notification, query an HR system) from within any function. Errors are propagated as exceptions.

View Source

IsCalendarWorkDay(DateTime?)

Test for calendar working day

Declaration
public bool IsCalendarWorkDay(DateTime? moment = null)
Parameters
Type Name Description
DateTime? moment

Work date (default: today)

Returns
Type Description
bool
View Source

IsCalendarWorkDay(string, DateTime?)

Test for calendar working day

Declaration
public bool IsCalendarWorkDay(string calendarName, DateTime? moment = null)
Parameters
Type Name Description
string calendarName

The calendar name

DateTime? moment

Test day (default: today)

Returns
Type Description
bool
View Source

Log(LogLevel, string, string, string)

Add a log

Declaration
public void Log(LogLevel level, string message, string error = null, string comment = null)
Parameters
Type Name Description
LogLevel level

The log level

string message

The log message

string error

The log error

string comment

The log comment

View Source

LogDebug(string, string, string)

Add a debug log

Declaration
public void LogDebug(string message, string error = null, string comment = null)
Parameters
Type Name Description
string message

The log message

string error

The log error

string comment

The log comment

View Source

LogError(Exception, string, string)

Add an error log using an exception

Declaration
public void LogError(Exception exception, string message = null, string comment = null)
Parameters
Type Name Description
Exception exception

The exception

string message

The log message, default is the exception message

string comment

The log comment

View Source

LogError(string, string, string)

Add error log

Declaration
public void LogError(string message, string error = null, string comment = null)
Parameters
Type Name Description
string message

The log message

string error

The log error

string comment

The log comment

View Source

LogFatal(Exception, string, string)

Add a fatal log using an exception

Declaration
public void LogFatal(Exception exception, string message = null, string comment = null)
Parameters
Type Name Description
Exception exception

The exception

string message

The log message, default is the exception message

string comment

The log comment

View Source

LogFatal(string, string, string)

Add a fatal log

Declaration
public void LogFatal(string message, string error = null, string comment = null)
Parameters
Type Name Description
string message

The log message

string error

The log error

string comment

The log comment

View Source

LogInformation(string, string, string)

Add an information log

Declaration
public void LogInformation(string message, string error = null, string comment = null)
Parameters
Type Name Description
string message

The log message

string error

The log error

string comment

The log comment

View Source

LogVerbose(string, string, string)

Add a verbose log

Declaration
public void LogVerbose(string message, string error = null, string comment = null)
Parameters
Type Name Description
string message

The log message

string error

The log error

string comment

The log comment

View Source

LogWarning(string, string, string)

Add a warning log

Declaration
public void LogWarning(string message, string error = null, string comment = null)
Parameters
Type Name Description
string message

The log message

string error

The log error

string comment

The log comment

Implements

IDisposable

Extension Methods

ConsoleExtensions.WriteProperties(object, bool)
ValueTypeExtensions.GetValueType(object)
ObjectInfo.GetPropertyValue(object, string)
ObjectInfo.GetPropertyValue<T>(object, string, T)
ObjectInfo.ResolvePropertyValue(object, string)
ObjectInfo.SetPropertyValue(object, string, object)
  • View Source
☀
☾
Back to top Generated by DocFX