Restrict edit of sublist fields in Client script:

You can use the validateLine event in your client script to prevent users from adding lines when certain conditions are met. The function you use simply needs to return a Boolean value: true if the line addition can continue, false if it should not.

Similarly, there is a validateDelete event you can use to prevent line removal when certain conditions are met.

Lastly, and also following a similar pattern, there is a validateField event you can use to prevent the user from modifying a field value when certain conditions are met. It is not quite disabling the field, but it will prevent them from changing the value.

Adding these event handler functions to your client script should allow you to prevent the changes you desire, though it does not actually disable any of the fields.

Sample code:

function validateField(context) {
            var currentRecord = context.currentRecord;
            var sublistName = context.sublistId;
            var sublistFieldName = context.fieldId;
            var line = context.line;
            if (sublistName === 'item') {
                if (sublistFieldName === 'quantity') {
                    throw error.create({
                    name: 'EDIT_DISABLED',
                    message: 'The value cannot be edited'
                });
                }
            }
            return false;
        }

Leave a comment

Your email address will not be published. Required fields are marked *