How to Copy Reference List using Action Button

Solved

Action Button’s AddRecord expects the Reference Field in the format shown here,

"[index_num_1,index_num_2,......]" 

This can be achieved by creating a list of the Reference Field and converting it to a String

str(list($Experiments.id))

with the final code looking like:

#action button linked field within Sample table

actions = []

# Adding Samples
actions.append(
  ["AddRecord", "Sample", None, {
    "Experiments": str(list($Experiments.id)),   # Reference List , works as expected
    "Process_ID": $Process_ID.id,  # Reference Field, works as expected
    "Tests": $Tests,   # Standard Field, works as expected 
    "Results": $Results,
    "Repeats": $Repeats,
  }])
  
return {
  "button": "Duplicate {} records".format(len(actions)-1),
  "description": 'Duplicate "{}" records from {}'.format( len(actions), $Process_ID.Process_Name),
  "actions": actions,
}
2 Likes