These functions and classes are available within a form plugin via the global gx variable.

no-examples
interface gx {
    Activity: (
        options: QuickActivityOptions,
        data: Record<string, unknown>,
    ) => Promise<{ createdCase: string; result: Record<string, unknown> }>;
    CaseId: CaseId;
    getDataset: (
        widgetId: string,
        datasetId: string,
        caseId: string,
        settings?: DatasetClientQueryGetter,
        returnRealPromise?: boolean,
    ) => Promise<
        {
            definition: Record<string, unknown>;
            info: Record<string, unknown>;
            rows: Record<string, unknown>[];
        },
    >;
    getFormData: (
        widgetId: string,
        formId: string,
        caseId: string,
        options?: Record<string, unknown>,
    ) => Promise<Record<string, unknown>>;
    getTemplate: (
        caseId: string,
        templateId: string,
        widgetId: string,
        widgetRightsCase?: string,
        taskId?: string,
        activityId?: string,
        viewId?: string,
    ) => Promise<string>;
    load: (domElement: HTMLElement) => void;
    log: {
        toast: (
            messages: string,
            level: 1 | 2 | 3 | 4 | 5,
            settings: LogSettings,
        ) => void;
        trace: (messages: any, level?: 1 | 2 | 3 | 4 | 5) => void;
    };
    PickList: any;
    plugin: { createFormAction: (tag: string) => formAction };
}

Properties

Activity: (
    options: QuickActivityOptions,
    data: Record<string, unknown>,
) => Promise<{ createdCase: string; result: Record<string, unknown> }>

use API.v1.postActivity instead.

CaseId: CaseId
const caseId = gx.CaseId('1:1540:4453');
caseId.compareTo('1:1540:4453:1'); // returns true
gx.CaseId('xxxx'); // throws errors "xxx is not a valid caseId"
getDataset: (
    widgetId: string,
    datasetId: string,
    caseId: string,
    settings?: DatasetClientQueryGetter,
    returnRealPromise?: boolean,
) => Promise<
    {
        definition: Record<string, unknown>;
        info: Record<string, unknown>;
        rows: Record<string, unknown>[];
    },
>

Retrieve a dataset

use API.v1.getDataset instead.

getFormData: (
    widgetId: string,
    formId: string,
    caseId: string,
    options?: Record<string, unknown>,
) => Promise<Record<string, unknown>>

use API.v1.getForm instead.

getTemplate: (
    caseId: string,
    templateId: string,
    widgetId: string,
    widgetRightsCase?: string,
    taskId?: string,
    activityId?: string,
    viewId?: string,
) => Promise<string>

Retrieve a template

load: (domElement: HTMLElement) => void

Use this to load widgets within a certain domElement

gx.load(document.querySelector('.someClass'));
log: {
    toast: (
        messages: string,
        level: 1 | 2 | 3 | 4 | 5,
        settings: LogSettings,
    ) => void;
    trace: (messages: any, level?: 1 | 2 | 3 | 4 | 5) => void;
}
PickList: any

Turn any field into a picklist with static data

const pfield = fields('picklistField').input()[0];
const data = [{id: 1, name: 'John'}, {id: 2, text: 'Jane'}];
const picklist = gx.PickList(null, null, null, {data}, pfield);
// Update with new data
const newData = [{id: 3, name: 'Mike'}, {id: 4, text: 'Michelle'}];
picklist.updateStaticData(newData);
plugin: { createFormAction: (tag: string) => formAction }

Type declaration

  • createFormAction: (tag: string) => formAction
    gx.plugin.createFormAction('postcode-retrieval-plugin')
    .setDisplayName('Postcode retrieval');
    .addField(...);
    .addGroup(...);
    .addSetting(...);
    .setAction(...);