Error Checking Data in Applescript

See below - This script generates an error when the input data fields are not all present. So I added error checking but the error persists. Why would this be?

I suppose that the record doesn’t contain a citationkey element. It does contain a keyelement, though. May be that’s what you want to use?
I think it might be more helpful to post scripts and error messages as text (not as images, as you did). The text in the screenshot is way too small to be read comfortably.

The image can be expanded to original size by clicking on it.

The record in question has an undefined CitationKey element - I am trying to figure out how to ignore that so it does not cause the whole script to abort.

The original script is here:

You could split this line into multiple ones, each of them wrapped in a try/end statement:

set {theKey, theTitle, theURI, theZoteroID, theDateModified} to {citationKey, title, uri, itemID, dateModified} of theRef

Similar to other snippets of the script:

	try
		set theTitle to |shortTitle| of theRef
	end try

The image can be expanded to original size by clicking on it.

I’m aware of that. It’s just more cumbersome then to read the script inline.

In addition to Christian’s suggestion, you could use one or several if … then blocks.
Cf https://stackoverflow.com/questions/1993176/how-do-i-check-if-a-key-in-a-record-exists

Or: figure out, why the citation key is absent. I suppose that one would want it in the output of this script.

Thanks - I will try that

Thanks - that may be helpful

As to “why” the citationkey is absent, that can happen if the Title field is missing in Zotero and perhaps in other situations in Zotero when a citation is incomplete. Ideally BetterBibText would allow the user to define a default CitationKey (such as “BlankKey”) in such a situation, but it seems easier for me to error-check the script than to convince a developer to add that other feature to BetterBibText.