How to re-trigger loadOptions?

Hello,

I’m implementing “get” function for my node and for one of parameters I want to load options depending on another option. However what I’m seeing is that loadOptions is only triggered once.

Here is my resource description

export const description: INodeProperties[] = [
	{
		displayName: 'Operation',
		name: 'operation',
		type: 'options',
		noDataExpression: true,
		options: [
			{
				name: 'Create',
				value: 'create',
				description: 'Create a new entity',
				action: 'Create an entity',
			},
			{
				name: 'Get',
				value: 'get',
				description: 'Get an entity by ID',
				action: 'Get an entity',
			},
			{
				name: 'Delete',
				value: 'delete',
				description: 'Delete an entity',
				action: 'Delete an entity',
			},
		],
		default: 'create',
		displayOptions: {
			show: {
				resource: ['entity'],
			},
		},
	},
	{
		displayName: 'Database Name or ID',
		name: 'database',
		type: 'resourceLocator',
		default: { mode: 'list', value: '' },
		required: true,
		description:
			'Select the Fibery database to operate on. Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code/expressions/">expression</a>.',
		displayOptions: {
			show: {
				resource: ['entity'],
			},
		},
		modes: [
			{
				displayName: 'From List',
				name: 'list',
				type: 'list',
				placeholder: 'Select a database...',
				typeOptions: {
					searchListMethod: 'getDatabases',
					searchable: true,
				},
			},
			{
				displayName: 'ID',
				name: 'id',
				type: 'string',
				placeholder: 'Enter Database ID...',
			},
		],
	},
	...create.description,
	...get.description,
	...deleteOperation.description,
];

and here is my properties for get.operation

const properties: INodeProperties[] = [
	{
		displayName: 'Entity ID',
		name: 'entityId',
		type: 'string',
		required: true,
		default: '',
		placeholder: 'e.g., 123e4567-e89b-12d3-a456-426614174000',
		description: 'The UUID of the entity to retrieve',
	},
	{
		displayName: 'Select fields',
		name: 'fields',
		type: 'multiOptions',
		noDataExpression: true,
		default: ['fibery/id'],
		description:
			'Comma-separated list of fields to include in the response (optional). Choose from the list, or specify IDs using an <a href="https://docs.n8n.io/code/expressions/">expression</a>.',
		typeOptions: {
			loadOptionsDependsOn: ['database'],
			loadOptionsMethod: 'loadFields',
		},
	},
];

So as you can see I noted that ‘fields’ is dependant on ‘database’. However loadFields don’t get called on ‘database’ change.

What’s also interesting is that when I change ‘loadOptionsDependsOn’ to [‘entityId’] then loadFields gets re-triggered every time I change id. Is there something wrong with ‘database’ definition?

Thanks in advance for any tips

Noticed similar bug for Notion node:

If you switch property from one single-select to another the options become stale. Until you hit manually “refresh list“ the values don’t update

hello @Misha

As far as I know, loadOptions work with options or multiOptions types. Try changing the list type of the database property to options

Not sure I understood you.

Yeah it seems it works if I change database from resourceLocator to options but is it correct though?
Feels like a bug to me. Does it mean that options field with loadOptions can’t depend on resourceLocators?