View Single Post
Old 04-01-2021, 03:05 PM   #485
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
I just spent some time to try to test book var scopes. I finally got there. It works very well.

First, I was confused about when Chain Variables actions ran. I forgot about the meaning of the "iterate" box. This is why I asked about getting the ids of the scope. With "iterate" I don't need that, and in any event I could get the list using a from_selection('id'). As far as I am concerned you can forget about that "request".

Once I checked 'Iterate' things fell together. The following chain searches all books for "important titles" that contain the word 'all' and updates some metadata. The first action uses an "all books" scope. All the books with "important" titles have a book var set. This action is followed by two single field edit actions with book_var scope that update metadata in the "important" books, specifically storing an altered title and the strlen of the original title.

I tried setting the scope of the second metadata action to "books changed". It worked, but I struggled with the results until I remembered that a book doesn't "change" if the metadata stored an action is the same as already there.

The attached zip contains the chain, in case you are interested.
Attached Files
File Type: zip book_var_scope_test.zip (597 Bytes, 592 views)

Last edited by chaley; 04-01-2021 at 03:21 PM.
chaley is offline   Reply With Quote