Autogenerate complex Date / Count based Title I might be pushing the limits of what's possible with Craft's autogenerated title capability, but in any event I'd like to figure out the best path to arrive at my goal.
We have an internal parts inventory with unique IDs assigned in the format YYYYMMDD-NNN. I'd like to recreate that same autogenerated format as we move our data to Craft.
Logically, the concept is &quot;today's date plus the sequential ID incrementing for the parts recorded one that day&quot;. Each day, we start back at  '-001' (e.g., '20210305-001', '20210305-002',...).
I've tried the following code in Title Format autogeneration input, but either have the syntax messed up or am pushing beyond the capability of what's possible with autogenerating for a title field in craft.
{# Desired unique ID format = 'YYYYMMDD-NNN' #}
{% if not object.id %}
    {% set uniqueID = craft.entries.section('inventory')
    .order('postDate DESC')
    .first()
    .title %}
    {% set datePortion =  uniqueID | slice(0, 8) %} {# extract YYYYMMDD from string #}
    {% if datePortion == 'now'|date('Y-m-d') %}
        {% set count = uniqueID | slice(9, 3) %}
        {{ datePortion ~ '-' ~ count + 1 }} {# increment today's count for next part #}
    {% else %}
        {{ 'now'|date('Y-m-d') ~ '-001' }} {# first entry in a new day #}
    {% endif %}
{% else %}
    {{ object.title }}
{% endif %}

Hope someone has a more clever and elegant solution - thanks!
Unless I'm missing something, you should be able to use the seq Twig function (docs) and use something like:
{{ 'now'|date('Ymd') ~ '-' ~ seq('now'|date('Ymd'), 3) }}

This would generate the format you need YYYYMMDD-NNN and reset the NNN every new day.
Sequences are stored in your sequences database table.