Attachment Plugin not working with defined Attachment Forms

Hello,

We have been using custom attachment forms for the various attachment fields on our Specify 6 instance without issue. E.g. CollectionObjectAttachmentBRI

Where the workflow is to browse for the attachment using

uitype=“browse”

However when the form is initialised in our Specify 7 instance the browse does not work and the “Choose a file or drag it here” attachment plugin that initializes with the default ObjectAttachment form does not load, leaving no way to add new attachments. (The green arrow to add a new COAttachment does not prompt a way to actually browse or add the attachment.

I can reset the CollectionObject view to use the default ObjectAttachment subview, but this removes all the fields that we would typically include with the Attachment:

Is there a way to get the “Choose a file or drag it here” attachment plugin to start by default on the custom CollectionObjectAttachmentBRI form?

The XML for the subview is the same as the default with the exception of the viewname:

cell type=“subview” id=“attachments” viewname=“CollectionObjectAttachmentBRI” name=“collectionObjectAttachments” initialize=“btn=true;icon=CollectionObjectAttachment” colspan=“2”>

We’re running Specify 7 v7.9.6.2
Specify 7 System Information - 2025-04-03T05_26_48.752Z.txt (1.2 MB)
and Specify 6.8.03

Hello,

We’re still having this issue and any solution I’ve tried has either broken Specify 6 or Specify 7.
We’ve also noticed another issue in that the Attachment Image Metadata is not showing up on the Specify 7 forms.
In Specify 6, the process acts as follows:
There is a custom Collection Object Attachment form and an Attachment Image Meta- CollectionObjectAttachmentBRI & AttachmentImageAttributeBRI
We can use the browse button to add a file, and then add metadata as well - like in the screenshot above.

In Specify 7 using these custom forms there is no option to browse or add a file - the “Choose a file or drag it here” dialogue does not show.
If I reset it back to ObjectAttachment form, I only get the fields “File Name, Title, Make Public” - In Specify 6 this only shows up when adding an image from the form:

I’ve tried creating a default attachment form ObjectAttachment with the fields we use in CollectionObjectAttachmentBRI (e.g. Original file name, title, subject, Image creation date etc.) but the this breaks Specify 6 entirely.

The Image Metadata is also not showing up under any circumstances - I’ve tried creating adding the AttachmentImageAttributeBRI at different levels to see if it’ll show up, but it doesn’t appear at all on the Specify 7 forms, only the comments field shows up.

Here is what our custom CollectionObjectAttachmentBRI form looks like: (I’m not sure why this isn’t showing up in the forum post)

The CollectionObjectAttachment form. 110px,5dlu,p:g

Note: the fields for this form all use “attachment.field” syntax - if i remove this, it doesn’t work in Specify 6. If I don’t remove this, it causes issues in Specify 7 if I try to set this form as the default ObjectAttachment form.

And here is the AttachmentImageAttributeBRI form:

<viewdef name="AttachmentImageAttributeBRI Form" class="edu.ku.brc.specify.datamodel.AttachmentImageAttribute" type="form" gettable="edu.ku.brc.af.ui.forms.DataGetterForObj" settable="edu.ku.brc.af.ui.forms.DataSetterForObj" useresourcelabels="true">
	<desc>The Attachment Image Attribute form.</desc>
	<columnDef>125px,5dlu,p:g</columnDef>
	<rowDef auto="true" cell="p" sep="2px"/>
	<rows>
		<row>
			<cell type="label" labelfor="photographer"/>
			<cell type="field" id="photographer" name="text2" uitype="text"/>
		</row>
		<row>
			<cell type="label" labelfor="context"/>
			<cell type="field" id="context" name="text1" uitype="combobox"/>
		</row>
		<row>
			<cell type="label" labelfor="imageType"/>
			<cell type="field" id="imageType" name="imageType" uitype="combobox"/>
		</row>
		<row>
			<cell type="label" labelfor="magnification" label="Magnification"/>
			<cell type="field" id="magnification" name="magnification" uitype="text"/>
		</row>
		<row>
			<cell type="label" labelfor="creativeCommons" label="Licence"/>
			<cell type="field" id="creativeCommons" name="creativeCommons" uitype="combobox"/>
		</row>
	</rows>
</viewdef>

Any help with a method for getting the “Choose a file or drag it here” dialogue box to appear on the CollectionObjectAttachmentBRI form in Specify 7 would be great, and if there’s any reason that the attachmentImageAttributeBRI form isn’t showing as a subview that would also be very helpful.

Apologies for the block of text. Any help would be greatly appreciated!

Hi @leobrimblecombe,

I sincerely apologize for the late response. I’m not sure how this fell off our radar, so I really appreciate you responding this week!

Can you share a copy of your database with me? We can take a look and see why you are experiencing the behavior you have described! Note that support for Specify 6 is limited, and the following explanation applies solely to Specify 7:


To give some more context, Specify will only look at the ObjectAttachment view definition when viewing an attachment from Gift, Loan, Permit, Preparation, Locality, Reference Work, Storage, Taxon, etc. as listed below.

If you are looking at a Collection Object’s attachment, it uses the CollectionObjectAttachment view definition.

If you are looking at the Attachment form directly (not via a link between a base record (e.g. Collection Object)), it uses the AttachmentsForm view definition.

At the moment, ObjectAttachment cannot be edited using the visual form editor, but that will be fixed in the v7.12.0 release of Specify which is coming soon. You can still edit this via XML directly.

From Editing Forms in Specify -

View Definition Names

In most cases, the table has the same view name as its default view (e.g. Collection Object will display the view definition named CollectionObject, Accession will display Accession, and Collecting Event will display CollectingEvent).

If you are showing a subview like attachmentImageAttribute, you can explicitly reference the AttachmentImageAttributeBRI view definition like so on the ObjectAttachment view definition:

<row>
    <cell type="subview" id="imageatt" viewname="AttachmentImageAttributeBRI" name="attachment.attachmentImageAttribute" colspan="3" />
</row>

Some tables use a special name for the view definition that is not always the same as the name of the table. The entire list of such cases are included below:

Table Name Default View Name
Attachment AttachmentsForm
Collecting Trip CollectingTripForm
Journal JournalForm
Other Identifier OtherIdentifiers
FieldNotebookAttachment ObjectAttachment
FieldNotebookPageSet ObjectAttachment
FieldNotebookPageSetAttachment ObjectAttachment
GiftAttachment ObjectAttachment
LoanAttachment ObjectAttachment
PermitAttachment ObjectAttachment
PreparationAttachment ObjectAttachment
LocalityAttachment ObjectAttachment
ReferenceWorkAttachment ObjectAttachment
RepositoryAgreementAttachment ObjectAttachment
StorageAttachment ObjectAttachment
TaxonAttachment ObjectAttachment
TreatmentEventAttachment ObjectAttachment

Source Code: Specify Data Model

Hi Grant,

Thanks for the info on this issue!

Sorry for not getting back to this sooner, but I’m back looking at this issue now and only really have one main question that’s still bugging me.

Note: I was only using the fact that I could overwrite the ObjectAttachment field as a workaround to the fact that the CollectionObjectAttachment view definition wasn’t functioning as expected.
I think in an ideal situation there wouldn’t need to be any use of ObjectAttachment at all, but it worked as an okay way to get both the “Choose a file or drag it here” prompt to come up and also have the custom fields we want in the attachment view - unfortunately this workaround of creating an ObjectAttachment form at the Attachment level to supercede the default one breaks our existing Specify 6 process (which we don’t expect to support much longer, but can’t go around breaking core functionality in either (unfortunately for me.))

Ignoring the object attachment and lower level attachment form stuff, can you see any reason why our CollectionObjectAttachment view definition (CollectionObjectAttachmentBRI in this case) doesn’t have the prompt to “Choose a file or drag it here”?

(Apologies for the repeat of the same information that’s in the above messages - I’m trying to lay it out as clearly as I can :sweat_smile:)
On the CollectionObject form it is called like this:

<cell type="subview" id="attachments" viewname="CollectionObjectAttachmentBRI" name="collectionObjectAttachments" initialize="align=right;btn=true"/>

and on the CollectionObjectAttachment view definition it looks like this:

<viewdef>
	<desc>The CollectionObjectAttachment form.</desc>
	<!--columnDef>110px,2dlu,p:g,5dlu,100px,2dlu,85px</columnDef> -->
	<columnDef>110px,5dlu,p:g</columnDef>
	<rowDef auto="true" cell="p" sep="2px"/>
	<rows>
		<row>
			<cell type="label" labelfor="1"/>
			<cell type="field" id="1" name="attachment.origFilename" initialize="editoncreate=true" cols="30" uitype="browse" isrequired="true"/>
		</row>
		<row>
			<cell type="label" labelfor="title"/>
			<cell type="field" id="title" name="attachment.title" uitype="text" cols="30"/>
		</row>
		<row>
			<cell type="label" labelfor="subject"/>
			<cell type="field" id="subject" name="attachment.remarks" uitype="text" cols="30"/>
		</row>
		<row>
			<cell type="label" labelfor="dateImaged"/>
			<cell type="field" id="dateImaged" name="attachment.dateImaged" uitype="text"/>
		</row>
		<row>
			<cell type="label" labelfor="copyrightHolder"/>
			<cell type="field" id="copyrightHolder" name="attachment.copyrightHolder" uitype="text"/>
		</row>
		<row>
			<cell type="label" labelfor="copyrightDate"/>
			<cell type="field" id="copyrightDate" name="attachment.copyrightDate" uitype="text"/>
		</row>
		<row>
			<cell type="label" labelfor="license"/>
			<cell type="field" id="license" name="attachment.license" uitype="text"/>
		</row>
		<row>
			<cell type="label" labelfor="credit"/>
			<cell type="field" id="credit" name="attachment.credit" uitype="text"/>
		</row>
		<row>
			<cell type="label" labelfor="eDocs"/>
			<cell type="field" id="eDocs" name="attachment.metadataText" uitype="text"/>
		</row>
		<row>
			<cell type="subview" id="imageatt" viewname="AttachmentImageAttributeBRI" name="attachment.attachmentImageAttribute" colspan="3"/>
		</row>
		<row>
			<cell type="label" labelfor="Comments"/>
			<cell type="field" id="Comments" name="remarks" uitype="textareabrief" rows="3"/>
		</row>
	</rows>
</viewdef>

I feel like there should be something that should be some way to trigger this form to come up with the “Choose a file or drag it here” picker without resorting to changing any of the underlying code or replacing it with the ObjectAttachment form/a frankenstein’d version of it.

I should note that this exact same format and issue occurs with our ConservEventAttachmentBRI, LocalityAttachmentBRI, AgentAttachmentBRI, CollectingEventAttachmentBRI, LoanAttachmentBRI and a couple other forms - most of these I’ve just opted not to use our custom forms for and are just the default (non-edited) ObjectAttachment form on PROD, but that does mean we miss the functionality of being able to add any attachment info other than the default fields of Filename, Title and MakePublic

Let me know if there’s anything missing or anything else you’d like from me.
Once again, thanks for all the help on this - I really appreciate it.

Best regards,
Leo