Customizable Extra/General Fields

I searched on this topic, and while I found relevant discussions I did not find an exact answer. Does Zotero have any way to add in a GUI field(s) in the "extra" or other general fields? As an example, JabRef allows users to customize the "general" fields (link: https://docs.jabref.org/setup/generalfields). My use case would be for setting up fields such as "sample size" or "research methodology."

My searches lead me to believe this isn't possible with Zotero, but I wanted to confirm. I suspect I could manually do this by adding "samplesize:xxx" etc. to the "extra" field, but a more clean approach would be appreciated.

Thanks all.
  • You can add as many lines as you want to Extra, so you can put this sort of data in Extra like this:
    Sample size: 123
    Design: Longitudinal

    Custom user fields are planned for the medium-term, but aren't currently available.
  • That is good to know. If I can ask another question, if there anyway for Zotero to 'prepopulate' the extra field so that the reviewer just adds the value? I assume the reviewer would need to write both the key and value each time. Thank you!
  • edited May 7, 2020
    You are using this for a systematic review I take it?

    You could write a script to add these values to all of the Extra fields in your library.
    https://www.zotero.org/support/dev/client_coding/javascript_api#batch_editing

    I think this should work. Fill in the values for groupID and newValues below, then run it using the JavaScript runner in Tools -> Developer -> Run JavaScript. The groupID is the group number you see in the URL for the group on zotero.org.

    var fieldName = "extra";
    var groupID = "<ENTER GROUP NUMBER HERE>";
    var newValues = "<ENTER KEYS YOU WANT HERE, SEPARATE LINES WITH '\n'>";

    var fieldID = Zotero.ItemFields.getID(fieldName);
    let libraryID = Zotero.Groups.getLibraryIDFromGroupID(groupID);
    var ids = await Zotero.Items.getAll(libraryID, true, false, true);
    if (!ids.length) {
    return "No items found";
    }
    await Zotero.DB.executeTransaction(async function () {
    for (let id of ids) {
    let item = await Zotero.Items.getAsync(id);
    let mappedFieldID = Zotero.ItemFields.getFieldIDFromTypeAndBase(item.itemTypeID, fieldName);
    let oldValue = item.getField(mappedFieldID ? mappedFieldID : fieldID);
    let newValue = oldValue + "\n" + newValues;
    item.setField(mappedFieldID ? mappedFieldID : fieldID, newValue);
    await item.save();
    }
    });
    return ids.length + " item(s) updated";

  • edited May 7, 2020
    Thanks. I am using this for collaborative literature reviews and potentially systematic reviews (e.g., multiple reviewers feeding into a single report).

    I started reviewing the tutorial for writing a plugin, but this seems a bit easier. I just gave it a go and ran into an error: oldValue not defined.

    I see why it is being raised. If I define an oldValue I can get the script to work beautifully on the documents that have the 'extra' field set to whatever I define as 'oldValue'.

    I first tried to remove the s.addCondition line, but that threw an error "Error: '22' is not a valid field for type 14."

    Next, I tried to change the s.addCondition to s.addCondition(fieldName, 'is', 'any'); but that did not find any records.

    Is there a way to apply this to all documents, regardless of what content is in their extra field already? I looked at the search basics on the link you recommended, and it looked like I could search without specifying conditions so I'm not sure why the error is being thrown.

    I appreciate your quick responses and help.
  • Oh, sorry, forgot to change a line there. I've edited the code to return all of the items in a library.
  • Thank you! That worked perfectly.
  • I'd like to second the request for custom user fields through the GUI in a similar way to how it is currently possible to add authors/creators.
    At the moment I cannot find a way to add information in the "extra" space in a way that it exports properly as multiple separately labelled columns in a CSV file which is causing a lot of extra manual labour.
    For multilingual records I really need a way to duplicate many fields and the "extra" "catch all"
    doesn't work for CSV export :(
  • edited April 5, 2021
    .
Sign In or Register to comment.