Dynamic relation data defined inside template

WHAT DO YOU RECOMMEND

The user could define a formula by which, when the template is used to create an object, dynamic data is inserted into either the object itself or its relation(s).

HOW COULD IT BE DONE

Shortcode or markdown-related user input is a basic method. Obsidian uses this, for example, to insert the present date/time when a template is used to create an object. With the development of a simple formula language, more complex UI models could be used for improved UX, such as a dropdown list from the (template) editor. Obviously the more development work applied to such a model, the less user input would be required to create such variables in templates.

REAL WORLD USE CASES

In the end, the point is to use some formula or variable within a template to automatically fill data into the object or its relations when the template is triggered. Examples of user-entered formula language can be found by review of Obsidian’s template variables. There the user applies code such as {{user}}, where “user” is the variable name pulled from metadata. Another related example is Obsidian’s {{date}} variable used in templates to insert the present date at the time of the template’s application creating a new object (file).

RECOMMENDED ALTERNATIVES

Alternatively, Anytype devs could create such variables input via a UI similar to the way relations are now user-applied. Or perhaps there is a simpler way I haven’t considered.

ADDITIONAL CONTEXT

This FR relates, but does not include the concept of a dynamic formula to apply variable data at the time of object creation.

This FR includes request for suggested drop-down input that could be used for improved UI/UX.

3 Likes

WHAT DO YOU RECOMMEND

I would like to use the [@] operator in the names of objects, to be able to set their name automatically upon creation through a template.

HOW COULD IT BE DONE

Just like you can use the [@] in a normal text block to set, for example, ‘@today’ or ‘@tomorrow’, I would like to set that for the name in the template, and get it applied upon object creation.

REAL WORLD USE CASES

I would use this feature in two different cases:

  1. I have a type called ‘Training Record’. I use it to record my progress in the gym, and I usually set the name to the current date. If the template had ‘@today’ in the template name, when I create a new training record the name would automatically be set to ‘03-10-2023’.
  2. I have a type called ‘Workplan’. I use it to layout the planning of tasks for the day, and have many for each day I need a workplan. The use case is the same as before: template with ‘@today’, and name set as the current date upon object creation.

RECOMMENDED ALTERNATIVES

Currently, this behavior isn’t even possible within the content of the object itself, which I find to be a wasted opportunity for automation.
Of course, the only alternative I see is, just as we have to do now, set those parameters manually. This works, but I believe this could be easily implemented.

Thanks for reading!

It would be cool to automate beyond just the object name.

For example, I have templates where there is a set that is filtered to only objects that have the object in a relation (eg. Book A has a set with only “Quote” objects from Book A), so it would be cool automate that (in this case, have a filter for Relation X > Has all of > @current-object).

2 Likes