Creating tags from dataviewJS

I suspect this isn’t possible, but I thought I would ask.

I have a dataviewJS script that inserts a text string (no white spaces) with a hashtag added in front (to create a new tag.) This text is based on a calculation from a variable in the front matter.

Obsidian recognizes this calculated text as a tag (it’s highlighted appropriately) and I can click on it to call up other files with this tag. However, Obsidian doesn’t recognize this generated tag in global searches. I realize that it is a calculated value, so it doesn’t exist as a tag until the calculation is completed.

Is there any work around for this? It would be very handy to be able to create a new tag based on a calculation. I realize that I can do this via the front matter using Templater, but that is not consistent with the way that these notes were generated (from an import and merge from a CSV file.)

Any thoughts?

Thanks in advance!

Things I have tried

If there is some template engine engaged when doing the import and merge, that would be the better option. Second best, I think, would be to trigger a javascript (could be dataviewjs) when you’re importing, and then let that calculate and insert the tags into the frontmatter. Last option, would be to use just a dataviewjs script when you open the note, which I would suggest has two tasks: Firstly, check if the value has already been converted, and secondly (if it has been converted) trigger a call to app.fileManager.processFrontMatter() to add the new tag(s) and a marker to denote that this file has been converted.

Examples of doing calls to processFrontMatter() has been given quite recently in this forum.

Thanks for pointing me in the right direction! This is very helpful.
BTW - the import is being handled by JSON/CSV importer. I don’t know if there is a way to run a script during import - I don’t think it handles anything complicated during the import beyond dropping values into handlebar fields.
I will have a look at all three options in any case.