# funcmap

## Value

An Object containing zero or more type-specific properties - named after the Zotero item types - and an (optional) `DEFAULT` property.

#### Type-specific properties

Each property should be defined as follows :

* **Name** : the property name has to follow the Zotero data scheme. An old nomenclature of item types is available [here](https://aurimasv.github.io/z2csl/typeMap.xml).
* **Value** : the property's value should be a string, corresponding to a function name.&#x20;

For example, defining `funcmap.book`  with the value `"customBookFormat"` will have the extension use the `customBookFormat` function for all items of type `book`.

#### DEFAULT property

If the `funcmap.DEFAULT` property is defined, the extension will **always fall back** on the function it names if no specific function has assigned to an item's type. \
\&#xNAN;*>> The extension's built-in metadata template will never be used.*

## Usage in the extension <a href="#usage" id="usage"></a>

When importing an item's data into Roam, the extension will first check the item's type (i.e, its `data.itemType` property) and use it to look for the name of the formatting function that should be used to produce Roam blocks.

The extension's query path will check the existence of the following, and use the first defined value :

1. `zoteroRoam_settings.funcmap[itemType]`, which can be used to provide a specific formatting function for a particular item type. See [Type-specific properties](#type-specific-properties).
2. `zoteroRoam_settings.funcmap.DEFAULT`, which can be used to provide a user-defined default formatting function. See [DEFAULT property](#default-property).
3. The extension's built-in formatting function, `getItemMetadata` .

## Examples

&#x20;:pencil2: *Assigning custom functions to a few item types - no use of DEFAULT*

```javascript
// This presupposes the following :
// window.customBookFormat = function(item){ ... }
// window.customPaperFormat = function(item){ ... }

// For item types other than Book | Conference Paper | Journal Article,
// the built-in function getItemMetadata will be called.

zoteroRoam_settings = {
    // dataRequests: {...},
    funcmap: {
        book: "customBookFormat",
        conferencePaper: "customPaperFormat",
        journalArticle: "customPaperFormat"
    }
}
```

&#x20;:pencil2: *Assigning a custom function for a specific item type (book section) + use of DEFAULT*

```javascript
// This presupposes the following :
// window.customChapterFormat = function(item){ ... }
// window.customDefaultFormattingFunction = function(item){ ... }

// The built-in function getItemMetadata will never be called.

zoteroRoam_settings = {
    // dataRequests: {...},
    funcmap: {
        bookSection: "customChapterFormat",
        DEFAULT: "customDefaultFormattingFunction"
    }
}
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://alix-lahuec.gitbook.io/zotero-roam/v0.6/customization/other/funcmap.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
