View Single Post
Old 02-12-2021, 01:42 AM   #309
capink
Wizard
capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.
 
Posts: 1,207
Karma: 1995558
Join Date: Aug 2015
Device: Kindle
Quote:
Originally Posted by ownedbycats View Post
Question: How would I set up a template for single-field edit to add an entry to a tag-like?

I have a tag-like #kobocoll for Kobo collections. I'd like to add certain entries depending on the presence of certain entries in #genre column - e.g. if "fantasy" or "science fiction" are present, add "Fantasy & Sci-Fi" to #kobocoll.

thank you!
It would be something along those lines ...

Code:
program:
	genre = field('#genre');
	kobocoll = field('#kobocoll');
	intersection = list_intersection(genre, 'fantasy,science-fiction', ',');
	if intersection == '' then
		kobocoll
	else
		strcat(kobocoll, ',Fantasy & Sci-Fi')
	fi
Edit: The template processor in single field edit has been modified to do the following:
  • If the template returns a value identical to the current value, it will be discarded and no change will happen.
  • If the template returns an empty string, the plugin will unset the column value. This includes all data types (text, numerals, dates ... etc)

Last edited by capink; 02-12-2021 at 11:57 PM.
capink is offline   Reply With Quote