View Single Post
Old 04-05-2023, 02:53 PM   #1063
chaley
Grand Sorcerer
chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.
 
Posts: 12,495
Karma: 8065348
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
Quote:
Originally Posted by ownedbycats View Post
I'm having a bit of trouble figuring out how formulas work and am wondering if I'm misusing it here.

Code:
program: 
## Field guides, fanfiction exchanges, and various other unordered series
collections = first_non_empty(
	'Golden Guides' in $series,
	'Mass Effect Big Bang \d{4}' in $series,
	'Spectre Requisitions \d{4}' in $series,
	'N7 Exchange \d{4}' in $series,
	'Across Dark Space \d{4}' in $series,
	);

	if collections then columnupdate_seriesindex(0) fi
This is the code of columnupdate_seriesindex(). It changes the seriesindex to the argument.

This works as expected if I run it on a single book - if the series matches 'collections' it changes series_index to 0. It also works if I run it on two books that match or two books that don't match.

If I run it on two books where one matches and the other doesn't, it just results in an empty window (and the matched book fails to update). I'm thinking it's checking both books at once instead of each one separately.
The python template runs on a selection. After thought, I suggest that your action chain uses a selection modifier (a template search using code similar to above) to change the selection to the books you want, then uses a formula action to update all selected books.

Or a Search using Templates followed by a Selection Modifer to select all books in the current library view.
chaley is offline   Reply With Quote