How to get the attachment path when a item is select?

item.getFilePath() works only when a item is selected. I am planning to write a function to delete the attachment when the item is removed when the zotfile is applied. Or is there a solution to remove the linked files when the items are removed?
  • edited March 7, 2021
    getFilePath() only returns cached paths. Use await item.getFilePathAsync() in general.
  • thanks @dstillman .

    It also works only when a attachment item is selected. I would like to seek a function work for a regular item.

    It prompts me 'Error: getFilePathAsync() can only be called on attachment items' when a regular item is selected.

    I used these codes:

    var selectedItems = ZoteroPane.getSelectedItems();
    var item = selectedItems[0];
    return await item.getFilePathAsync()
  • I checked that page, and the codes return the full text.

    And I would like to obtain the path of the fulltext such as 'E:\Jianguo\references\Bhat et al_2021_Emerging processing technologies for improved digestibility of muscle proteins.pdf' just as when an attachment item is selcted when using the codes:

    var selectedItems = ZoteroPane.getSelectedItems();
    var item = selectedItems[0];
    return await item.getFilePathAsync()
  • I checked that page, and the codes return the full text.
    The point there isn't the full text — it's that that example shows how to get attachment items, which is what you need to run getFilePathAsync() on.
  • Got it, I made it.
Sign In or Register to comment.