specify6 icon indicating copy to clipboard operation
specify6 copied to clipboard

Accession Bus Rule preventing removal of divisionCBX field on AccessionCO viewdef

Open melton-jason opened this issue 4 years ago • 1 comments

The AccessionCO form has a field called divisionCBX that I would like to not appear on the form. However, whenever I move the field into the commented out section of the XML code, the whole AccessionCO form stops working. In other words, when I open the collection object form and click the + button next to the accession field, the accession form will only appear if the divisionCBX field is on the AccessionCO form.

Reported by the University of Colorado

As per the quote, the University of Colorado would like to remove the "Division" field from the form. However, when the field is commented out, the + button does not open the AccessionCO form and seemingly does nothing.

This is because Specify raises a NullPointerException (see attached error log below)

specify_error

The XML that was commented out within the AccessionCO viewdef: <cell type="field" id="4" name="divisionCBX" uitype="combobox" ignore="true"/>

Investigation into the Exception

The error specifically is being raised by the following code. https://github.com/specify/specify6/blob/94365dd01dad48482c6c9b0722001568bd98f76f/src/edu/ku/brc/specify/datamodel/busrules/AccessionBusRules.java#L242-L243

Thus, the variable tf more than likely is null. tf seems to be null due to the creation of the variable divComp, which is shown below https://github.com/specify/specify6/blob/94365dd01dad48482c6c9b0722001568bd98f76f/src/edu/ku/brc/specify/datamodel/busrules/AccessionBusRules.java#L231

Now the reasoning of why tf being null makes sense. Specify is trying to look for an object with id="4" on the AccessionCO viewdef, and it is unable to find any.

Workaround

My hypothesis was confirmed by creating a field and giving it an id="4". The XML I used to confirm this was as simple as <cell type="field" id="4"/>. However, this alone does not solve the issue. Instead, it creates a text field whose value defaults to the current division. This is due to the first code snipped that raised the exception (line 243), which creates tf, and gives it a default value equal to the accession's division.

The Solution (While still having <cell type="field" id="4" name="divisionCBX" uitype="combobox" ignore="true"/> commented out)

  • Create a field with colspan=0 and assign it id=4.

    • <cell type="field" id="4" readonly="true" colspan="0"/>
  • Comment out the division label (which creates the Division: text where the division combo box is supposed to go)

    • Find/Comment out: <cell type="label" id="divLabel" label=" " initialize="align=right"/>

melton-jason avatar Sep 29 '22 21:09 melton-jason

I am not really expecting a "fix" for this. I figured I would post this here in case anyone else has the same issue and finds the solution here, or could be pointed here.

melton-jason avatar Sep 29 '22 22:09 melton-jason