Add params to an extra_field

Hello, 

I'm working on a script that is going to append options/params to an extra_field (in an extra_table): 
 
I have not found a simple way to fetch the existing alternatives without using the searchEngine to look up the correct field in the extra_fields-table: 

String fieldName = "x_myfield";
// Get current field params
SearchEngine extraFieldParamSearch;

extraFieldParamSearch.addField("extra_fields.id");
extraFieldParamSearch.addField("extra_fields.target_extra_table");
extraFieldParamSearch.addField("extra_fields.params");
extraFieldParamSearch.addCriteria("extra_fields.field_name", "OperatorEquals", fieldName);
if (extraFieldParamSearch.select() > 0)
{
  // params are split by \n
  String[] parameters = extraFieldParamSearch.getField("extra_fields.params").split("\n");
  for (Integer i = 0; i < parameters.length(); i++)
  {
    String parameter = parameters[i].stripLeadingAndTrailing("\n");

    if (parameter.beginsWith("option="))
    {
      printLine(parameter.after("option="));
    }
  }
}

I found this blog on how to sort the values: 
https://community.superoffice.com/en/developer/blog/sorting-cs-extra-fields-list-values/

I could possibly just add new options by inserting a new "options=value" here (by doing some minor changes to the code in the blog), but it looks like 'overkill' in my case.. 

Is there an easier way? 

//Eivind



RE: Add params to an extra_field

Hi,

In cases where you have need to be able to easily add "options" I would recommend implementing field as a separate table instead. Manipulating text field with "option" list thru script is not optimal.

By: Michel Krohn-Dale 18 May 2020