Dynamic INodeProperties required field

Hello,

I have a INodeProperties that is required or not depending on a previous properties selection.
I found in previous thread that we can define dynamic string properties Dynamic Node Properties , however I was not able to apply similar solution for the boolean property.

{
		displayName: 'Parent Code',
		name: 'crmParentCode',
		type: 'string',
		required: true, // <-- **HERE** 
		displayOptions: {
			show: {
				resource: [
					'customerHierarchy',
				],
				operation: [
					'upsert',
				],
			},
		},
		default: '',
	}

Do you have an idea if this is possible ?

Thanks,
Wassim

Perhaps our resident node builder @marcus can help with this one?

Hi Wassim,
the displayOptions allow you to show or hide parameters depending on the value of other parameters. The required field cannot be dynamic. If your parameter is required only in certain conditions you can make it optional and implement a check in your node’s execute function (if your node is programmatic style). Once you implemented a check you can throw a NodeOperationError with an error message telling the user that your parameter is required for that operation.

Here are some examples of nodes throwing a NodeOperationError in certain conditions.

2 Likes

Hi Marcus,
I was wondering if your parameter was of type “options”, how can we address the issue since it is always required even if we change it to false?