The component id of the current view instance.
The configuration of the component to render.
The rendered HTML of the view.
The configuration of the view to render.
The viewFields of the view.
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;
});
The viewFields to set the condition on.
The condition to check whether the view field is disabled.
Optional
componentId: stringThe id of the component.
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('%');
});
The fields on which the validation applies.
The name of the validation rule.
The message to show when the view field is invalid.
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: stringThe id of the component.
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'];
});
The names of the view fields to add the condition to.
The condition that will determine if the field is required.
Optional
componentId: stringThe id of the component.
Opens the data source for a picker or dropdown list.
CSL.writeView.openDataSource('productPicker', componentId);
The name of the view field.
Optional
componentId: stringThe id of the component.
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);
The viewFields to set the condition on.
Optional
componentId: stringThe id of the component.
Remove a validation for the specified view fields.
CSL.writeView.removeFieldValidation(['productPrice', 'monthlyProfit'], 'No%Character');
The fields on which the validation applies.
The name of the validation rule.
Optional
componentId: stringThe id of the component.
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']);
The names of the view fields to remove the condition from.
Optional
componentId: stringThe id of the component.
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'});
The names of the fields to check the updateFormFieldAfterSelection.
The values to set for the form fields that need to be updated.
Optional
componentId: stringThe id of the component.
Generated using TypeDoc
This class represents the API for custom scripting related to write views. You can access all the methods by using the namespace
CSL.writeView
.