Display options in node development

Hi,

So I have been Bothering Jon for a bit in direct messages. I thought I would post it here so I don’t have to bother Jon with it all the time. :slight_smile:

I am trying to have a clean bit of code. I have actually been messing around for a while and now doing a complete rework of the node I am developing. Was getting too complicated with al the work arrounds I was trying to do.

I want to keep it simple now. For each resource their are some operations to perform. They are not all the same and have a lot of differences and similarities. Rather than to create a list of options separate for every resource I would like to use the display options to filter what is possible for that resource.
I cannot get this to work. Below is my Resource and operation property. Jon gave me the tip to use " ‘/Resource’ " instead of " resource " as this is used in the wait node. But apparently I am doing something wrong, because I cannot get this to work here.

			{
				displayName: 'Resource',
				name: 'resource',
				type: 'options',
				options: [
					{
						name: 'Contacts',
						value: 'contacts',
					},
					{
						name: 'Estimates',
						value: 'estimates',
					},
					{
						name: 'Products',
						value: 'products',
					},
					{
						name: 'Projects',
						value: 'projects',
					},
					{
						name: 'Sales Invoices',
						value: 'sales_invoices',
					},
					{
						name: 'Time Entries',
						value: 'time_entries',
					},
					
				],
				default: 'contacts',
			},
			{
				displayName: 'Operation',
				name: 'operation',
				type: 'options',
				options: [
					{
						name: 'Get',
						value: 'get',
						description: 'Get record(s) of the specified Resource',
					},
					{
						name: 'Add',
						value: 'add',
						description: 'Adds a new object of the specified Resource',
					},
					{
						name: 'Add Note',
						value: 'addNote',
						description: 'Adds a new Note to the specified Resource',
						displayOptions: {
							show: {
								'/resource': [
									'contacts',
									'estimates',
									'sales_invoices',
									'time_entries',
								],
							},
						},
					},
					{
						name: 'Edit',
						value: 'edit',
						description: 'Edits an object of the specified Resource',
					},
					{
						name: 'Delete',
						value: 'delete',
						description: 'Delete a record by Id',
					},
					{
						name: 'Delete Note',
						value: 'deleteNote',
						description: 'Delete a note by Id',
						displayOptions: {
							show: {
								'/resource': [
									'contacts',
									'estimates',
									'sales_invoices',
									'time_entries',
								],
							},
						},
					},
				],
				default: 'get',
				description: 'Operation to perform',
			},

As you can see in my code I want the addition and deletion of notes to be possible for certain resources not all. Now I get them shown for all with this setup:

Morning @BramKn,

I have made a note to have another look at this one later today. The / option is only for additional options under the existing Operation though from what I understand.

The way we handle it for Operations is to make mutltiple operations each with their own operation definition so in this case we would probably make 6 description files one for each resource and put the definitions for each one in that file that way if you need to change something in the future it is less likely to break something.

Hi @Jon

Thanks, would be nice if this was made possible so there is more flexibility for node development. For example some of my resources aren’t that big with regards to operations possible. So being able to combine those would be nice to keep it simple.

1 Like

Hey @BramKn,

Makes sense to me, On the plus side though it shouldn’t be blocking and you can still work on the node :slight_smile:

Hey @Jon

I wish it would block me. spending way too much time on this(in the weekend). But that’s mostly because of the reworks and the API that isn’t ideal. :sweat_smile:

1 Like