Coming soon: Your brand new Help Center & Community! Get a sneak-peek here

Add params to an extra_field


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.addCriteria("extra_fields.field_name", "OperatorEquals", fieldName);
if ( > 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="))

I found this blog on how to sort the 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? 


RE: Add params to an extra_field


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.

Von: Michel Krohn-Dale 18. Mai 2020