|  03-23-2013, 07:29 AM | #1 | 
| Addict            Posts: 296 Karma: 32153 Join Date: Dec 2008 Device: Kindles (e-ink) | 
				
				Custom yes/no column built from long text column
			 
			
			I have a custom column "foo" of type "Long text, like comments, not shown in the tag browser" which either contains nothing at all or some text. I'd like to have a simple "Yes/No" column "bar" that, in the library view, shows if "foo" contains anything. So I added said "Yes/No" column of type "Column built from other columns" and used this template: program: test(select(field('#annotations'),'.*'),'Yes ','No') Unfortunately, this function always returns "No". Even when replacing the '.*' with 'e' (because I had prepared "foo"'s content to contain it), it still returned "No". I've experimented with just using test() but whatever I tried, it simply either returned "Yes" or "No" for *all* entries, regardless of "foo"'s actual content. Can someone please lend me a hand here? :) | 
|   |   | 
|  03-23-2013, 10:17 AM | #2 | |
| Well trained by Cats            Posts: 31,249 Karma: 61360164 Join Date: Aug 2009 Location: The Central Coast of California Device: Kobo Libra2,Kobo Aura2v1, K4NT(Fixed: New Bat.), Galaxy Tab A | Quote: 
 Code: program: test(select(field('#annotations'),''),'No','Yes') | |
|   |   | 
| Advert | |
|  | 
|  03-23-2013, 10:24 AM | #3 | 
| Addict            Posts: 296 Karma: 32153 Join Date: Dec 2008 Device: Kindles (e-ink) | 
			
			Yes, indeed, I've tried that, too (and just did again with 0.9.24 just to make sure), and that only serves to invert the display (before, everything was "No", now everything is "Yes") but doesn't fix the issue.
		 | 
|   |   | 
|  03-23-2013, 10:34 AM | #4 | |
| Well trained by Cats            Posts: 31,249 Karma: 61360164 Join Date: Aug 2009 Location: The Central Coast of California Device: Kobo Libra2,Kobo Aura2v1, K4NT(Fixed: New Bat.), Galaxy Tab A | Quote: 
  ). Inverting the logic (not foo:true) has worked in other places, which is why I tossed it into the pot. chaley will be around pretty soon and probably point to the error of our ways   | |
|   |   | 
|  03-23-2013, 06:56 PM | #5 | 
| Grand Sorcerer            Posts: 12,525 Karma: 8065948 Join Date: Jan 2010 Location: Notts, England Device: Kobo Libra 2 | 
			
			Why are you using field ('#annotations') instead of field ('#foo')?
		 | 
|   |   | 
| Advert | |
|  | 
|  03-23-2013, 07:21 PM | #6 | 
| Addict            Posts: 296 Karma: 32153 Join Date: Dec 2008 Device: Kindles (e-ink) | |
|   |   | 
|  03-23-2013, 07:28 PM | #7 | 
| Grand Sorcerer            Posts: 12,525 Karma: 8065948 Join Date: Jan 2010 Location: Notts, England Device: Kobo Libra 2 | 
			
			You almost certainly don't want the function select, which operates on lists of colon separated items. You probably want the function contains, which operates on plain text. The regexp for contains would be something like . (a period), testing if the field contains at least one character.
		 | 
|   |   | 
|  03-23-2013, 07:44 PM | #8 | |
| Addict            Posts: 296 Karma: 32153 Join Date: Dec 2008 Device: Kindles (e-ink) | Quote: 
 So, the solution to my problem as initially described is rather simple: program: contains(field('#foo'),'.','Yes','No') | |
|   |   | 
|  | 
| 
 | 
|  Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post | 
| how to move value(s) of tag column to a custom made column | zoorakhan | Library Management | 0 | 12-08-2012 03:53 AM | 
| custom date column from two state column | Dopedangel | Library Management | 7 | 01-03-2012 08:20 AM | 
| No search/replace on custom long text column? | CWatkinsNash | Library Management | 2 | 06-20-2011 05:57 PM | 
| Converting text for a datetime custom column | kiwidude | Development | 2 | 02-26-2011 10:47 AM | 
| Custom text column with no HTML | mfaine | Calibre | 2 | 01-07-2011 01:12 PM |