Give us contact

Do you prefer to ask us directly?

Call us +420 605 203 938 (the Czech Republic)

or use this contacts

AyMINE

Related links


FI - Finance Management
Front-End Scripting

Object Global (g)

Object g with the method described bellow is always available. It provides methods for data manipulation as well as informtion about the environment and user behaviour. Global object is the default functionality provided by the frm module.

Do you miss any function? Ask us for help? Some other methods are provided by higher-level modules so that there might be avaiailable what you need for you project.s

dateAgeMin

dateAgeMin(strDate: string | Date) -> number

Returns the date difference from the current datetime in minutes.

  • A day has 1440 minutes, so a 1-day old date will return 1440.
  • Dates in the future return negative values, while dates in history return positive values.

        Example: dateAgeMin(dtCreated) > 1440 checks if a record is more than 1 day old.
    

currency

currency(getMark?: boolean) -> string

Returns the primary user/client currency. If getMark is true, it returns the currency mark (e.g., €/$/Kč) instead of the name (e.g., EUR/USD/CZK).

        Example: currency(true) returns €/$/Kč, currency() returns EUR/USD/CZK.
    

currencyVal

currencyVal(amount: iAttrVal, fcurrency: string | boolean = false, ret0: boolean = false, secondPart: boolean | string = false) -> string

Returns the value formatted with a currency mark. You can specify the currency or use the default client currency.

  • amount: The value to format.
  • fcurrency: Currency short code (e.g., EUR) or false for the default client currency.
  • ret0: When true, returns 0 for an empty field.
  • secondPart: If specified, adds the second unit (e.g., €/MD).

assert

assert(assertion: any) -> boolean

Checks if the given assertion is valid. Returns true if the value is a non-zero number or true, otherwise false.

        Example: assert(5) returns true, assert(0) returns false.
    

isHistory

isHistory(strDate: string | Date, checkDates: boolean = true) -> boolean

Returns true if the given date is in the past (historical). If checkDates is true, compares on a daily basis (today is not considered history).

isActiveInt

isActiveInt(from: string | Date, to: string | Date) -> boolean

Checks if the current date is within a given interval. The function returns false if the start date is in the future, or if the end date has passed.

safeString

safeString(val: string) -> string

Checks if a string is safe to show, typically used for displaying user input safely.

        Example: safeString(userInput) returns a sanitized version of the input string.

isValidID

isValidID(checkID: string) -> boolean

Checks if the given ID is valid. It must not include any of the characters { or .. It also returns false for empty or null values.

isValue(...args: string | any) -> boolean

Returns true if all provided attributes have a set value (non-undefined, non-empty).

testDate(strDate: string) -> string

Test function for validating date conversion on Safari. NEVER USE IN PRODUCTION.

getDate(item: string | Date, short: boolean = false) -> string

Returns the date part of a datetime. If short is true, returns the short date format.

getTime(item: string) -> string

Returns the time part of a datetime.

_weekday(d: Date) -> number

Returns the day of the week (0 for Sunday, 6 for Saturday) from the provided date.

dtRound(roundTo?: number) -> string

Rounds the current time to the nearest time-minute interval (default is 30 minutes).

dtDate(what?: 'Date' | 'Month' | 'FullYear' | 'Hours', count?: number, startDate?: Date) -> Date | string

Returns the actual timestamp or shifts it by a specified interval.

dayInMonth(day: number | string, month: number, year: number, rel: boolean = false, sql: boolean = false, point: Date = undefined) -> Date | string

Returns the first or last day of the month, or a specific day. It can calculate relative or absolute dates.

dateDiff(start: string | Date, end: string | Date) -> string

Returns the date difference between two given dates as a human-readable string.

now: string

Returns the current timestamp as a string (equivalent to @now).

dtfWorkDays(dateIn: Date | string, dayCount: number, retDate = false, morningTime?: string) -> Date | string

Calculates a future date considering working days (weekdays only). Optionally sets the time to 9:00 AM.

coloredSections(basicStyle: string, ...args: string[]) -> string | false

Creates and returns styled sections with optional colors.

dtInterval(dtStart: Date | string, dtEnd: Date | string, workingOnly: boolean = true, negativeWarning: boolean = true) -> string

Converts an interval (start and end dates) into a human-readable format. Can consider only working days and display negative intervals.

dIntervalDays(dtStart: Date | string, dtEnd: Date | string, iconName?: string) -> string

Displays an interval in days, with optional icons and formatted date ranges.

dIntForPerson(duration: number) -> string

Converts an interval in days to a human-readable format (e.g., "2 years 3 months").

descFromMD

Function: Generate object description from markdown text.

Parameters:

  • str: The markdown string to be processed.

Returns: A string containing the description (first line or first few words).

Example:

descFromMD("# Title\nThis is a sample text.") // "Title"

sqlDLimit

Function: Prepares SQL dates for work with intervals in history or future.

Parameters:

  • interval: 'year', 'quarter', or 'month' - Specifies the time interval.
  • when: 'actual', 'past', or 'next' - Specifies the interval state.
  • what: 'first', 'last', or a field name - Specifies the first or last day of the interval, or a field for the SQL query.

Returns: A string representing the SQL query for the specified interval and date range.

Example:

sqlDLimit('quarter', 'past', 'first') // '2023-01-01'

ifset

Function: Returns the first or second variant based on a condition.

Parameters:

  • what: The condition to check.
  • first: The first value to return if the condition is truthy.
  • second: The second value to return if the condition is falsy.

Returns: A string (either the first or second variant based on the condition).

Example:

ifset(true, "Yes", "No") // "Yes"

log

Function: Sends information to the log.

Parameters:

  • info: The information to log.
  • desc: Optional description to add to the log.

Returns: A boolean value indicating whether the log was successful.

Example:

log("Hello, world!") // true

isMobile

Function: Returns whether the device is mobile.

Returns: A boolean indicating whether the device is mobile.

isCamera

Function: Returns whether the device has a camera.

Returns: A boolean indicating whether the device has a camera.

isApp

Function: Returns whether the application is running as a standalone app.

Returns: A boolean indicating whether the app is running as a standalone application.

isCtrl

Function: Returns whether the script was started with a Ctrl+Click.

Returns: A boolean indicating whether Ctrl+Click was used to start the script.

offline

Function: Checks or sets the offline mode.

Parameters:

  • newVal: Optional value to set the offline mode (boolean).

Returns: A boolean indicating whether the offline mode was set successfully or the current value.

Example:

offline(true) // false

today

Function: Returns the current date as a string.

Returns: A string representing the current date.

Example:

today() // "2025-06-03"

applName

Function: Returns the application name loaded for the client from settings.

Returns: A string representing the application name.

days_between

Function: Returns the number of days between two dates.

Parameters:

  • d1: The first date (string or Date).
  • d2: The second date (string or Date).

Returns: A string representing the number of days between the two dates.

Example:

days_between("2023-01-01", "2023-01-10") // "9"

icon

Function: Returns an icon based on the provided name and optional tooltip.

Parameters:

  • iconName: The name of the icon.
  • tooltip: Optional tooltip text.

Returns: A string representing the HTML for the icon.

iconList

Function: Builds a list of icons from a list of icon names.

Parameters:

  • iconList: A comma-separated list of icon names.
  • pattern: Optional pattern to filter the icons.

Returns: A string representing a list of icon HTML elements.

setBgColor

Function: Updates the background color according to the user's color settings.

Parameters:

  • color: The color to set.
  • addOpacity: Optional flag to add opacity to the background.

Returns: A string representing the updated background color.

setFgColor

Function: Updates the text color according to the user's color settings.

Parameters:

  • color: The color to set.

Returns: A string representing the updated text color.

validSingle

Function: Validates if a given string is valid based on predefined rules.

Parameters:

  • str: The string to validate.

Returns: A boolean indicating whether the string is valid.

valid

Function: Evaluates content and returns the first valid attribute.

Parameters:

  • args: A list of strings to check for validity.

Returns: A string representing the first valid attribute.

bg

Function: Sets the background color and applies it.

Parameters:

  • color: The color to set for the background.

Returns: A string representing the updated background color.

multiEnumSingleShort

Function: Retrieves a shortened enum value based on the provided value.

Parameters:

  • value: The string to check for the shortened enum value.
  • enumName: The name of the enum to search for.
  • retEmpty: The return value if no match is found.

Returns: A string representing the shortened enum value or the provided default value if not found.

enumIcon

Function: Returns the icon associated with an enum value.

Parameters:

  • short: The enum value to translate into an icon.
  • enumName: The name of the enum.
  • nameOnly: Optional. If true, only the icon name is returned. Defaults to false.

Returns: A string representing the icon or its name based on the provided parameters.

Warning: Use nameOnly for dynamic icons as they are used in further processing.

objectIcon

Function: Returns the icon for a specified object, either with or without a tooltip.

Parameters:

  • objName: The object name or object itself.
  • nameOnly: Optional. If true, only the icon name is returned. Defaults to false.
  • withHint: Optional. If true, the icon and a tooltip (name of the object) are returned.

Returns: A string representing the icon HTML or icon name.

objectIDFieldName

Function: Returns the ID field name for a specified object.

Parameters:

  • objName: The name of the object.

Returns: A string representing the object's ID field name.

Throws: An error if the object name is missing or invalid.

joinInternal

Function: Internal method used to join a list of words with a separator.

Parameters:

  • sep: The separator to use between the words.
  • words: The list of words to join.

Returns: A string representing the joined words, possibly wrapped in a span for styling.

join

Function: Joins words without any separator.

Parameters:

  • words: The list of words to join.

Returns: A string representing the joined words.

joinSep

Function: Joins words with a specified separator.

Parameters:

  • sep: The separator to use between the words.
  • words: The list of words to join.

Returns: A string representing the joined words with the separator applied.

joinSpace

Function: Joins words with spaces between them.

Parameters:

  • words: The list of words to join.

Returns: A string representing the words joined with spaces.

encaps

Function: Encapsulates a command for further evaluation, replacing certain characters.

Parameters:

  • command: The command to encapsulate.
  • level: Optional. The level of encapsulation.

Returns: A string representing the encapsulated command.

telForPerson

Function: Formats a telephone number for display.

Parameters:

  • item: The telephone number as a string.

Returns: A string representing the formatted telephone number.

dtForPerson

Function: Converts a date field into a human-readable format.

Parameters:

  • item: The date field to format.
  • format: The format to use ('DT', 'D', or 'T' for datetime, date, or time only). Defaults to 'DT'.

Returns: A string representing the formatted date or time.

iconed

Function: Adds an icon in front of a field if the field is not empty.

Parameters:

  • field: The field value to display.
  • iconName: The name of the icon to display.
  • iconTooltip: The tooltip for the icon.

Returns: A string representing the icon and field, or an empty string if the field is empty.

prefixed

Function: Adds a prefix to a field, optionally with a style.

Parameters:

  • prefix: The prefix to add before the field.
  • field: The field value to display.
  • style: Optional. The style to apply to the prefix and field.

Returns: A string representing the field with the prefix.

isNumber

Function: Returns true if the given value is a valid number (integer or float).

Parameters:

  • val: The value to check.

Returns: A boolean indicating whether the value is a valid number.

classID

Function: Returns the class ID for a given class name.

Parameters:

  • className: The name of the class.

Returns: A string representing the class ID, or a default value if the class is not allowed.

objIsInGroup

Function: Returns true if an object is in a specified group.

Parameters:

  • objName: The name of the object.
  • group: The group name to check.

Returns: A boolean indicating whether the object is in the group.

getObjWithGroup

Function: Returns an array of objects that belong to a specified group.

Parameters:

  • group: The group name to filter by.
  • forWHERE: Optional. If true, the result is returned as a comma-separated string suitable for a WHERE condition.

Returns: An array or string representing the objects in the specified group.

hasUserAttributes

Function: Returns true if an object has user-defined attributes.

Parameters:

  • objName: The name of the object.

Returns: A boolean indicating whether the object has user attributes.

getObjDesc

Function: Returns the description of an object, either from cache or translated.

Parameters:

  • objName: The name of the object.
  • objID: The object ID.

Returns: A string representing the object's description.

openLink

Function: Opens a new page with the specified link.

Parameters:

  • link: The URL to open in a new tab.

Returns: None.