Class ListItemFunctionCustomScripting

This class supports the functionality for custom scripting on list item functions. You can access all the methods by using the namespace CSL.listItemFunction.

Hierarchy

  • CslBase
    • ListItemFunctionCustomScripting

Properties

componentId: string = ''

The component id of the current view instance.

Accessors

  • get componentConfig(): Component
  • The configuration of the component to render.

    Returns Component

  • get htmlElement(): any
  • The rendered HTML of the view.

    Returns any

  • get viewConfig(): UpdateView | MultiRecordView | SingleRecordView | CreateView
  • The configuration of the view to render.

    Returns UpdateView | MultiRecordView | SingleRecordView | CreateView

  • get viewFields(): ViewField[]
  • The viewFields of the view.

    Returns ViewField[]

Methods

  • Triggers the execution of a function on the component. If the execution has to be confirmed by the user, the user will still have to do this.

    // Execute the 'Order goods' function for where the stock is smaller than 150.
    const pageData = CSL.multiRecord.getPageData();
    var recordsToExecuteFunctionFor = Object.values(pageData).filter(pageItem => {
    return pageItem.stock < 150;
    });
    CSL.listItemFunction.executeFunction('Order goods', recordsToExecuteFunctionFor);

    // Deselect all rows. Select row with ids 1 and 6 and execute the 'Block Product' function.
    CSL.multiRecord.deselectAll();
    CSL.multiRecord.select(['1', '6']);
    CSL.listItemFunction.executeFunction('Block Product');

    // Execute a function and do something with the results.
    CSL.listItemFunction.executeFunction('Block Product').then((response) => {
    // Results from the function are here:
    console.log(response.results);
    }, (error) => {
    error.errors.forEach((err) => {
    console.error(err);
    });
    });

    Throws

    error when function is not found.

    Parameters

    • functionName: string

      The name of the function to execute.

    • Optional dataItems: {
          [key: string]: any;
      }[]

      The records to execute the function for. This is only applicable for the type ItemFunction. When no value is passed, all the selected items are taken.

    • forceExecution: boolean = false

      Whether the execution of the function should be forced. This will bypass any checks that would prevent the execution.

    • Optional componentId: string

      The unique identifier of the multi record view.

    Returns Promise<ListItemFunctionExecutionResults>

  • Get all functions of the current view or the one with the specified id.

    CSL.listItemFunction.getAllFunctions();
    

    Parameters

    • Optional componentId: string

      The id of the component to check.

    Returns ListItemFunction[]

  • Get list item function by its name.

    const addToStockFunction = CSL.listItemFunction.getListItemFunction('AddToStock');
    

    Parameters

    • functionName: string

      The name of the function.

    • Optional componentId: string

      The id of the component to find the function on.

    Returns any

  • Set the condition that will determine if the function is enabled. With a disabled function, the button or icon representing the function cannot be clicked. This will be set for functions in header and in row. The condition will be checked when an interaction in the view is made. (loadComplete, value changed, refresh, ...). Because this is extra configuration on the list item function, the most logical place to call this function is in the configuration script.

    To disable default Ometa buttons based on a condition, you need to prefix this with $$obiz-. Possible values are: $$obiz-New, $$obiz-Edit, $$obiz-Update, $$obiz-InlineEdit, $$obiz-Details, $$obiz-Refresh, $$obiz-Export, $$obiz-ContextSetter, $$obiz-AuditTrailDetails.

    // Disable 'AddToStock' function after 17:00h.
    const hourLimit = 17;

    CSL.listItemFunction.setEnabledCondition('AddToStock', () => {
    const currentHour = new Date().getHours();
    return currentHour < hourLimit;
    });

    Parameters

    • functionName: string

      The name of the function.

    • enableFunction: ((..._: any[]) => boolean)

      The function to set as the check.

        • (..._: any[]): boolean
        • Parameters

          • Rest ..._: any[]

          Returns boolean

    • Optional componentId: string

      The id of the component on which the function exists.

    Returns void

  • Set the condition that will determine if the function is enabled in the header. The condition will be checked when an interaction in the view is made. (loadComplete, value changed, refresh, ...). Because this is extra configuration on the list item function, the most logical place to call this function is in the configuration script.

    To disable default Ometa buttons based on a condition, you need to prefix this with $$obiz-. Possible values are: $$obiz-New, $$obiz-Edit, $$obiz-Update, $$obiz-InlineEdit, $$obiz-Details, $$obiz-Refresh, $$obiz-Export, $$obiz-ContextSetter, $$obiz-AuditTrailDetails.

    CSL.listItemFunction.setHeaderEnabledCondition('AddToStock', (dataSet) => {
    // Get the 'Broken'group.
    const brokenItems = dataSet.groups.find((g) => g.value === 'Broken');
    // Disable the 'AddToStock' function in the header if there are 3 or more broken items.
    return brokenItems ? brokenItems.length < 3 : true;
    });

    Parameters

    • functionName: string

      The name of the function.

    • enableFunction: ((..._: any[]) => boolean)

      The function to set as the check.

        • (..._: any[]): boolean
        • Parameters

          • Rest ..._: any[]

          Returns boolean

    • Optional componentId: string

      The id of the component on which the function exists.

    Returns void

  • Sets the condition for a header function. The condition will be checked when an interaction in the view is made. (loadComplete, value changed, refresh, ...). Because this is extra configuration on the list item function, the most logical place to call this function is in the configuration script.

    // Just set a new icon.
    CSL.listItemFunction.setHeaderIconCondition(
    'AddToStock',
    () => 'fab fa-android'
    );

    // Conditionally set an icon based on the amount of selected rows.
    CSL.listItemFunction.setHeaderIconCondition(
    'AddToStock',
    () => {
    let selected = CSL.multiRecord.getSelectedItems(componentId);
    if(selected.length > 2) {
    return 'fas fa-eye';
    } else {
    return 'fas fa-eye-slash';
    }
    });

    Parameters

    • functionName: string

      The name of the function to set the condition on.

    • iconCondition: Function

      The condition that returns a string.

    • Optional componentId: string

      The id of the component.

    Returns void

  • Sets the hide condition for a function in the header. The condition will be checked when an interaction in the view is made. (loadComplete, value changed, refresh, ...). Because this is extra configuration on the list item function, the most logical place to call this function is in the configuration script.

    To hide default Ometa buttons based on a condition, you need to prefix this with $$obiz-. Possible values are: $$obiz-New, $$obiz-Edit, $$obiz-Update, $$obiz-InlineEdit, $$obiz-Details, $$obiz-Refresh, $$obiz-Export, $$obiz-ContextSetter, $$obiz-AuditTrailDetails.

    CSL.listItemFunction.setHeaderVisibilityCondition('AddToStock', (dataSet) => {
    // Get the 'Broken'group.
    const brokenItems = dataSet.groups.find((g) => g.value === 'Broken');
    // Hide the 'AddToStock' function in the header if there are 3 or more broken items.
    return brokenItems ? brokenItems.length < 3 : true;
    });

    Parameters

    • functionName: string

      The name of the function.

    • hideCondition: ((..._: any[]) => boolean)

      The hide condition to set on the function.

        • (..._: any[]): boolean
        • Parameters

          • Rest ..._: any[]

          Returns boolean

    • Optional componentId: string

      The id of the component.

    Returns void

  • Set the condition that will determine if the function is enabled in the row. The condition will be checked when an interaction in the view is made. (loadComplete, value changed, refresh, ...). Because this is extra configuration on the list item function, the most logical place to call this function is in the configuration script.

    To disable default Ometa buttons based on a condition, you need to prefix this with $$obiz-. Possible values are: $$obiz-Edit, $$obiz-Update, $$obiz-Details, $$obiz-ContextSetter, $$obiz-AuditTrailDetails.

    CSL.listItemFunction.setRowEnabledCondition('AddToStock', (data) => data.Active === 'True');
    

    Parameters

    • functionName: string

      The name of the function.

    • enableFunction: ((..._: any[]) => boolean)

      The function to set as the check.

        • (..._: any[]): boolean
        • Parameters

          • Rest ..._: any[]

          Returns boolean

    • Optional componentId: string

      The id of the component on which the function exists.

    Returns void

  • Sets the condition for a row function. The row data will be sent with the condition. The condition will be checked when an interaction in the view is made. (loadComplete, value changed, refresh, ...). Because this is extra configuration on the list item function, the most logical place to call this function is in the configuration script.

    // Just set a new icon.
    CSL.listItemFunction.setRowIconCondition(
    'AddToStock',
    () => 'fab fa-android',
    );

    // Conditionally set an icon based on the productActive value
    CSL.listItemFunction.setRowIconCondition(
    'AddToStock',
    (row) => {
    if(row.data['productActive']) {
    return 'fas fa-eye';
    } else {
    return 'fas fa-eye-slash';
    }
    })

    Parameters

    • functionName: string

      The name of the function to set the condition on.

    • iconCondition: Function

      The condition to set on the row function.

    • Optional componentId: string

      The id of the component.

    Returns void

  • Sets the hide condition for a function in a row. The condition will be checked when an interaction in the view is made. (loadComplete, value changed, refresh, ...). Because this is extra configuration on the list item function, the most logical place to call this function is in the configuration script.

    To hide default Ometa buttons based on a condition, you need to prefix this with $$obiz-. Possible values are: $$obiz-Edit, $$obiz-Update, $$obiz-Details, $$obiz-ContextSetter, $$obiz-AuditTrailDetails.

    CSL.listItemFunction.setRowVisibilityCondition('AddToStock', (rowData) => rowData['Active'] === 'True');
    

    Parameters

    • functionName: string

      The name of the function.

    • hideCondition: ((..._: any[]) => boolean)

      The hide condition to set on the function.

        • (..._: any[]): boolean
        • Parameters

          • Rest ..._: any[]

          Returns boolean

    • Optional componentId: string

      The id of the component.

    Returns void

  • Sets the hide condition for a function. This will be set for functions in the header and in row. The condition will be checked when an interaction in the view is made. (loadComplete, value changed, refresh, ...). Because this is extra configuration on the list item function, the most logical place to call this function is in the configuration script.

    To hide default Ometa buttons based on a condition, you need to prefix this with $$obiz-. Possible values are: $$obiz-New, $$obiz-Edit, $$obiz-Update, $$obiz-InlineEdit, $$obiz-Details, $$obiz-Refresh, $$obiz-Export, $$obiz-ContextSetter, $$obiz-AuditTrailDetails.

    // Hide 'AddToStock' function after 17:00h.
    const hourLimit = 17;

    CSL.listItemFunction.setVisibilityCondition('AddToStock', () => {
    const currentHour = new Date().getHours();
    return currentHour < hourLimit;
    });

    Parameters

    • functionName: string

      The name of the function.

    • hideCondition: ((..._: any[]) => boolean)

      The hide condition to set on the function.

        • (..._: any[]): boolean
        • Parameters

          • Rest ..._: any[]

          Returns boolean

    • Optional componentId: string

      The id of the component.

    Returns void

Generated using TypeDoc