Using Values Array from Custom List In a formula

Hi I have a scenario where I have a number of Custom List Fields that are using the same List of values

for example AIS 1 , AIS 2 and AIS 3, Values cannot be repeated across the Fields and there is no Guarantee of Order.

So In AIS 3 I have created the following formula:

if field('AIS 2').nil? then nil
else
options = ['AIS12','AIS16','AIS20','AIS24','AIS28','AISb1','AISB2','AISER','AISY'];
remove = [field('AIS 1'), field('AIS 2')];

pick = options.excluding(remove); 

generate("Custom List", values: pick)
  
end

This Works fin, but I was wondering is there a way to Load the Options from the first Field i.e. AIS 1 ?
I was thinking something like

options = field('AIS 1').values 

I’ve tried a bunch of things but none seem to work

any tips or pointers ?

I’ve never tried this, but these possibilities occurred to me

  1. Create a hidden field (prefaced by two underscores) that hold a hard-coded list of values and use the ruby script to interact with it like the array. Don’t know enough about Ruby to suggest syntax, but conceptually, it should be doable.
  2. Create a Function in Mockaroo - Function editor that returns the array you’re looking to use and call that from the field’s formula

Thanks for the Tip
I did wonder if there was something that could be done with datasets?

But this seems to work just fine:-

1 Like

I’m not sure about the dataset portion, nothing came to mind when I was writing my original response, and that hasn’t changed.

I do like the solution you came up with though. I may have to steal that for my own schemas :slight_smile: