Create a new OmniOutliner Doc and apply a theme

Hi!
I’m just starting out with Omni Automation. I know JS pretty well, but I’m getting used to the new libraries with OA.
I’m basically trying to emulate the “Apply Template Theme” command to my newly created document (made via JXA), and apply the “Stylish with Level Styles” theme.
I know there must be a better way than to painstakingly recreate the theme via code. Did some studying up on named styles, but haven’t had much luck as of yet.
Any tips?

Thanks!

If you are trying to create a new OmniOutliner document with a specific theme, would opening a new document from a template be a more direct path? As far as I know, you can’t apply a template theme via the styles directly, so that would be a feature request. You can make changes to the base style for each attribute though like the examples at the bottom of the page at https://omni-automation.com/omnioutliner/style-document.html show.

You could also consider putting in an option to choose() to set the baseStyle by user selection like https://omni-automation.com/shared/url-choose.html as a way to set the baseStyle.

If you want the ability to import all attributes of a baseStyle from a template, please email in a request. A link to this post & a short overview should be enough. Anyone else looking for this ability should also send us email from Contact Omni under Help, or at omnioutliner@omnigroup.com to add more voices to the request.

Thanks,
Lanette

Thanks Lanette!
I seemed to have found a working solution, which is to set my default template for new documents to “Stylish with Style Levels”, and then have the first line in the script be:
rootItem.children.forEach(function(child){child.remove()})
That will get rid of all the text in the template but keep the styling. Then the rest of the script I can just do what I need to do and all the styling from the template will remain.

I’m attempting to programmatically create new documents depending on the day of the week, all within a single jxa script, so I’d prefer to just run the script to create and format the file instead of manually creating the the new document every day.

1 Like

Nice! I’m glad you found a solution and I hope it helps someone else.