- 
        Couldn't load subscription status. 
- Fork 41
Description
Problem Statement
When entering new records in Specify, users often must create related records, such as Determinations, Preparations, Collection Object Attributes, Collection Object Properties, Collectors, or Locality Details, to fill in all necessary details about a record. These are linked to the primary record being entered in the data model via 'Relationship Fields'. For example:
- collectionobject->- determinations
- collectionobject->- collectionObjectAttribute
- collectionobject->- preparations
Currently, Specify supports automatic creation of only three dependent tables (Collection Object Attribute, Determination, Preparation) via remote preferences settings (CO_CREATE_COA, CO_CREATE_DET, CO_CREATE_PREP). Extending this behavior to other relationships (e.g., Collector, Locality Detail) is not currently possible. This leads to extra clicks, risk of missing required fields, and inconsistent data entry workflows between users.
What we need is a generic, configurable mechanism to declare which relationship records should be auto-created, and under what circumstances, would streamline data entry, reduce errors, and provide a consistent framework for future tables. It should support (for example):
- locality->- localityDetails
- preparation->- preparationAttribute
- collectingevent->- collectors
- determination->- determiners
Functional Requirements
A migration from the current Remote Prefs implementation would be preferred if at all possible.
- Newly created subview records must appear automatically in the data-entry form.
- This should only be done for the first record added for that relationship.
- For example, if there is a Determinationautomatically created and the record is saved, a newDeterminationshould not be added automatically after a reload.
- If the user is using 'Carry Forward' or 'Clone', a new record should only be created in the case that a record in the configured relationship table (e.g. Determination) does not yet exist.
 
- For example, if there is a 
- This should support any relationship field that is a one-to-oneorone-to-manythat is rendered as asubview(including when shown as a button (see Automatically created Preparation in a button not assigned aPrepTypeID#3094))
- This new record should enforce any required fields (from either the schema or forms) and block saving if those requirements are not met
Proposed Solution
We could introduce a unified “auto-create” framework that can be applied to any relationship subview via:
View Definition:
Add a new attribute autocreate to <cell type="subview"> definitions in the view layout XML. For example:
<cell
  type="subview"
  viewname="Collector"
  id="12"
  name="collectors"
  colspan="12"
  rows="3"
  autocreate="true" />Acceptance Criteria
- 
Configurable via ViewDef 
 Any<cell type="subview" … autocreate="true">in a view layout XML must trigger automatic creation of exactly one related record the first time the parent record is saved. The default when the attribute is omitted or set to"false"is no auto-creation.
- 
First-Only Behavior 
 Once the initial dependent record has been created and saved, subsequent reloads, “Carry Forward,” or “Clone” operations must not spawn an additional record if any existing child record is present. Only if the subview is entirely empty (zero linked records) should a new record be created under"autocreate".
- 
One-to-One and One-to-Many Support 
 The framework must work for any relationship rendered as a subview—whether one-to-one or one-to-many, including subviews exposed via a button (initialize="btn=true).
- 
Enforce Required Fields 
 Auto-created records must honor all schema-level and form-level “required” constraints. If mandatory fields in the new child record lack values, the parent save operation is blocked and inline validation messages appear in the subview header.
Alternatives Considered
Extending the existing remote preferences approach by adding CO_CREATE_COLLECTOR, CO_CREATE_LOCALITYDETAIL, etc. This would require code changes for each new table, complicating maintenance and forcing a software release for every new auto-creation need.
Source and Stakeholders
- Philippe Verley (IRD) via Speciforum: request for automatic Collector creation on CE creation.
- Alexis Beck (NHM Geneva): auto-create LocalityDetail when creating a Locality.
- Nate Shoobs (OSU): auto-create preparation attribute
Discussed in #5993
Originally posted by grantfitzsimmons October 31, 2024
Requested by: Philippe Verley at IRD on the SpeciforumThe title purposefully mimics Automatically create a new Preparation, Determination, or Collection Object Attribute upon CO creation and says it all.
The
Embedded Collecting Eventoption and the three remote preferencesCO_CREATE_COA,CO_CREATE_DET&CO_CREATE_PREPproved very useful for easing up and securing new CO entry. Number of clicks is decreased and mandatory fields are clearly identified.A
Collecting Eventdoes not make sense without aCollectorin CAY herbarium. When I set up theCO_CREATEpreps, my colleagues immediately asked whether a newCollectorcould be automatically created as well, since it is mandatory in our data entry process.☝️ Can one automatically creates a new Collector upon CE creation ?
A quick look at
CollectionObjectinitialization andCollectionObject Resourcesinitialization seems to indicate that presently answer is no and that it may not be straightforward to implement.🤔 I'm also wondering why you decided to implement COA, DET & PRE creation through Remote Preferences ? (genuine question) Have you thought of a generalized approach in
viewdefresources, with for instance and XML attribute that would control the underlying resource creation ?<!-- COA subview with 'create' attribute --> <cell type="subview" viewname="CollectionObjectAttribute" id="10" name="collectionobjectattribute" colspan="14" initialize="" create="onDataEntry"/> <!-- Collector subview with 'create' attribute --> <cell type="subview" viewname="Collector" id="12" name="collectors" colspan="12" rows="3" create="onDataEntry" />The
createattribute could accept several values:
never(default)
onDataEntry: create the underlying object on new data entry only
ifEmpty: create the underlying object on new data entry or on data edition if empty- ?
Feel free to split the last bit to a separate thread "Generalizing automatic object creation on Data Entry" if the thought interferes with my 1st question on collector creation.
