Class WriteViewCustomScripting

This class represents the API for custom scripting related to write views. You can access all the methods by using the namespace CSL.writeView.

Hierarchy

  • CslBase
    • WriteViewCustomScripting

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

  • Adds a condition to determine whether the view field is disabled. When the view field is configured to be disabled, the field will always be disabled. The condition will be checked when an interaction in the view is made. (loadComplete, value changed, refresh, ...). Because this is extra configuration on the view, the most logical place to call this function is in the configuration script.

    // Disable delivery date and warehouse when the product is not yet delivered.
    CSL.writeView.addDisableFieldCondition(['deliveryDate', 'warehouse'], (rowData) => {
    return rowData['isDelivered'] === false;
    });

    Parameters

    • fieldNames: string[]

      The viewFields to set the condition on.

    • condition: Function

      The condition to check whether the view field is disabled.

    • Optional componentId: string

      The id of the component.

    Returns void

  • Adds a validation rule to the view field(s). When the condition returns a truthy value, the view field is invalid.

    CSL.writeView.addFieldValidation(['isDelivered'], 'MustBeDelivered', 'You must set product as delivered when providing a delivery date.', (controlValue, formValues) => {
    // Delivery date may not be filled in when product is not delivered.
    return (formValues['deliveryDate'] !== '' && controlValue === false);
    });

    CSL.writeView.addFieldValidation(['productPrice', 'monthlyProfit'], 'No%Character', `The value can't contain '%'. Database can't resolve '%'`, (controlValue) => {
    // The value can't contain '%'.
    return controlValue.toString().includes('%');
    });

    Parameters

    • fieldNames: string[]

      The fields on which the validation applies.

    • validationName: string

      The name of the validation rule.

    • errorMessage: string

      The message to show when the view field is invalid.

    • condition: Function

      The condition to determine whether the view field is valid. The condition can have 2 parameters. First parameter is the value of the control for which the validation is being triggered. Second parameter the form value.

    • Optional componentId: string

      The id of the component.

    Returns void

  • Add condition to view fields that will determine if the field is required. When the view field is configured to be required, the field will always be required. The condition will be checked when an interaction in the view is made. (loadComplete, value changed, refresh, ...). Because this is extra configuration on the view, the most logical place to call this function is in the configuration script.

    // When a product is delivered, the warehouse and the delivery date are required.
    CSL.writeView.addRequiredFieldCondition(['warehouseName', 'deliveryDate'], (rowData) => {
    return rowData['productIsDelivered'];
    });

    Parameters

    • fieldNames: string[]

      The names of the view fields to add the condition to.

    • condition: Function

      The condition that will determine if the field is required.

    • Optional componentId: string

      The id of the component.

    Returns void

  • Opens the data source for a picker or dropdown list.

    CSL.writeView.openDataSource('productPicker', componentId);
    

    Parameters

    • viewFieldName: string

      The name of the view field.

    • Optional componentId: string

      The id of the component.

    Returns void

  • Remove condition to determine whether the view field is disabled. When the view field is configured to be disabled, the field will always be disabled.

    // Disable delivery date and warehouse when the product is not yet delivered.
    CSL.writeView.removeDisableFieldCondition(['deliveryDate', 'warehouse'], componentId);

    Parameters

    • fieldNames: string[]

      The viewFields to set the condition on.

    • Optional componentId: string

      The id of the component.

    Returns void

  • Remove a validation for the specified view fields.

    CSL.writeView.removeFieldValidation(['productPrice', 'monthlyProfit'], 'No%Character');
    

    Parameters

    • fieldNames: string[]

      The fields on which the validation applies.

    • validationName: string

      The name of the validation rule.

    • Optional componentId: string

      The id of the component.

    Returns void

  • Remove condition from view fields that will determine if the field is required. When the view field is configured to be required, the field will always be required.

    CSL.writeView.removeRequiredFieldCondition(['warehouseName', 'deliveryDate']);
    

    Parameters

    • fieldNames: string[]

      The names of the view fields to remove the condition from.

    • Optional componentId: string

      The id of the component.

    Returns void

  • Triggers the save of the write view component.

    CSL.writeView.save();
    

    Parameters

    • Optional componentId: string

      The id of the component.

    Returns any

  • Update values for fields that have updateFormFieldAfterSelection configured.

    // update the fields that are configured as UpdateFormFieldsAfterSelection.
    CSL.writeView.updateFormFields(['productId'], {productName: 'Ab35F', productDescription: 'Bolt with 3.5mm diameter'});

    Parameters

    • fieldNames: string[]

      The names of the fields to check the updateFormFieldAfterSelection.

    • value: ValueObject<string>

      The values to set for the form fields that need to be updated.

    • Optional componentId: string

      The id of the component.

    Returns void

  • Validates the form of the write view component. Returns the errors of the form.

    CSL.writeView.validate();
    

    Parameters

    • Optional componentId: string

      The id of the component.

    Returns {}

    Generated using TypeDoc