Here are two python stored templates you can use for this.
This one returns the link associated with a value in a column.
Code:
python:
def evaluate(book, context):
arguments = context.arguments
if arguments is None or len(arguments) != 2:
raise ValueError('template needs 2 arguments: column, value')
db = context.db.new_api
links = db.get_link_map(arguments[0])
return links.get(arguments[1], '')
Example call:
Code:
program: get_links_for_value('series', '1632')
It returns the empty string if no link exists.
This template sets a link for a value in a column:
Code:
python:
def evaluate(book, context):
arguments = context.arguments
if arguments is None or len(arguments) != 3:
raise ValueError('template needs 3 arguments: column, value, link')
to_set_map = {arguments[1]:arguments[2]}
db = context.db.new_api
db.set_link_map(arguments[0], to_set_map)
return arguments[2]
It returns the link text if successful.
Example call:
Code:
program: set_link_for_value('series', 'Bah', 'some link')