Suppress "accessed" when DOI is present with biblatex-chicago

I've been happy with the doi=only option

Suppress URL if DOI is present in biblatex-chicago

to suppress URL when DOI is present. But, recently, I've started to have entries that have the accessed field for the URL. That is a nice feature because some journals require it together with the URL.

The problem is that the urldate field (printed as "accessed") is printed together with the DOI! I think the access field should be suppressed when doi=only. I suppose this is something that I should report to the maintainers of biblatex-chicago but is there a quick workaround?

Edit: Here is a self-contained example:

\documentclass{article}
\begin{filecontents}{references.bib}
@article{SomePaper,
title = {Some title},
author = {Some Author},
year = {1975},
journal = {Journal of Something},
volume = {5},
number = {2},
pages = {300--325},
doi = {12.3456/abcdef-ghijkl},
url = {https://some.organization.com/non-existent.pdf},
urldate = {2021-10-14},
}
\end{filecontents}
\usepackage[doi=only]{biblatex-chicago}
\begin{document}
\nocite{*}
\printbibliography
\end{document}


The reference list shows these words: "Accessed October 14".

Additional info:. I contacted the author of biblatex-chicago, who points out that the Chicago Manual includes examples of DOIs with "accessed" information. Upon reflection, I think that makes sense because in some disciplines small alterations like commas and typos could matter. In that sense, DOI'ed objects aren't stable enough. In our field (earth science), DOIs are regarded as permanent and the "accessed" information is almost never provided for DOIs.

Regardless, the maintainer of biblatex-chicago said s/he would consider adding another option, perhaps doi=onlynd, to surppress "accessed" when printing the DOI.

• Even though you mention biblatex-chicago, it would still help to see a full (small) document will all relevant setting. This would allow any persons willing to help copy your code, insert the prospective answer and test it before posting. The added benefit for you is that you can be sure that the answer works in your context. Oct 7, 2021 at 10:20
• @gernot Thanks for the comment. At the time, I was in the middle of writing a manuscript and didn't have enough time to deal with this. I've added a self-contained example.
– Ryo
Oct 31, 2021 at 4:50

Internally the option doi=only, sets the toggle cms@doionly, so we want to hook into bibliography and citations and clear out the access date (urlyear is sufficient) if that option is enabled and there is a DOI.

Conceptually, the following is not the nicest solution, but certainly one of the more straightforward ones.

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[backend=biber, doi=only]{biblatex-chicago}

\AtEveryCitekey{%
\iftoggle{cms@doionly}
{\iffieldundef{doi}
{}
{\clearfield{urlyear}}}
{}%
}
\AtEveryBibitem{%
\iftoggle{cms@doionly}
{\iffieldundef{doi}
{}
{\clearfield{urlyear}}}
{}%
}

\begin{filecontents}{\jobname.bib}
@article{kastenholz1,
author   = {Kastenholz, M. A. and Hünenberger, Philippe H.},
title    = {Computation of methodology\hyphen independent ionic solvation free
energies from molecular simulations},
subtitle = {I. The electrostatic potential in molecular liquids},
journal  = {Journal of Chemical Physics},
volume   = {124},
eid      = {124106},
date     = {2006},
url      = {https://aip.scitation.org/doi/10.1063/1.2172593},
urldate  = {2006-10-01},
doi      = {10.1063/1.2172593},
}
@article{kastenholz2,
author   = {Kastenholz, M. A. and Hünenberger, Philippe H.},
title    = {Computation of methodology\hyphen independent ionic solvation free
energies from molecular simulations},
subtitle = {I. The electrostatic potential in molecular liquids},
journal  = {Journal of Chemical Physics},
volume   = {124},
eid      = {124106},
date     = {2006},
doi      = {10.1063/1.2172593},
}
@article{kastenholz3,
author   = {Kastenholz, M. A. and Hünenberger, Philippe H.},
title    = {Computation of methodology\hyphen independent ionic solvation free
energies from molecular simulations},
subtitle = {I. The electrostatic potential in molecular liquids},
journal  = {Journal of Chemical Physics},
volume   = {124},
eid      = {124106},
date     = {2006},
url      = {https://aip.scitation.org/doi/10.1063/1.2172593},
urldate  = {2006-10-01},
}
\end{filecontents}