Help

Save the date! Join us on October 16 for our Product Ops launch event. Register here.

Re: Script to change field type

2489 1
cancel
Showing results for 
Search instead for 
Did you mean: 
Daniel_Toma
5 - Automation Enthusiast
5 - Automation Enthusiast

Hi All!

Can anyone provide some scripting advice - I want to create a script that changes a field type from Multiple Select to a Text field when it runs, and another script to do the reverse.

Thanks in advance for any feedback!

7 Replies 7

Scripts cannot change the field type of an existing field. Scripting app can create new fields, but it cannot delete fields.

Why do you want to change the field type?

Daniel_Toma
5 - Automation Enthusiast
5 - Automation Enthusiast

Many thanks Kuovonne, I did not realize this scripting limitation… I’m creating an airtable form that would include a multiselect dropdown field, however I want it to only show drop-down options that are currently present in that table. Older items which were previously selected as drop-down option (but are no longer selected in the table) would ideally be excluded from showing as drop-down options in the form. Currently, drop-down options will show all current and previously added drop-down options unless you go in and manually delete older ones no longer in use.

Interestingly, one way to clear the “old” unused options would be to convert a field from a drop-down to a text field and then back to a drop-down. It will result in the drop-down options only being the ones currently in the table.

I’m not sure if there is another way to automate the deletion of older drop-down items…

There is no way to programmatically delete choices from a multi-select field.
You might want to consider using a linked record field instead.

Daniel_Toma
5 - Automation Enthusiast
5 - Automation Enthusiast

Good to know, thanks for your help! :thumbs_up:

Josh_Stockbridg
4 - Data Explorer
4 - Data Explorer

Not certain if you landed somewhere with this yet.
but here is the solution using linked fields.

Have 2 tables

Table 1
image

  • all of your selections listed out in “Name” field
  • Date field (manual expiry date OR created/modified time)
  • [Any other applicable data you want to include]

Then create a view that filters out the data based on whatever date field you chose.
(i.e. I want all selections where the record was made within 30 days.)

image

next

Table 2
image

  • Name field is whatever you like, [but perhaps a formula field concatenating certain data together.]
  • Link field to Table 1 (when creating this make sure you select “Limit to view” toggle and select the view that filtered out the data in Table 1.

Form will replicate the linked field that has limitation to that view
image

Daniel_Toma
5 - Automation Enthusiast
5 - Automation Enthusiast

Thanks so much for the helpful feedback @Josh_Stockbridge!

robinzim
5 - Automation Enthusiast
5 - Automation Enthusiast

There is another reason it's desirable to change the field type: to reset an auto numbered column.

If you create an auto numbered column, then manually reorder records and want the auto numbering to start from 1 and go to N again, the only way to do that is to temporarily change the type to integer then back to auto number.

But it looks like I can't do that in a script. 😐

I just want my records numbered from 1 to N so I know the priority order I put them in.