The original wave template was created to access custom objects without namespace. What's the best way to make it work (meaning to deploy the template in a managed package and have it create dataset accessing the objects & fields in namespace context)?
An idea I had was to add a variable called "Namespace" to variables.json, add a WaveTemplateConfigurationModifier Apex to set it on beforeAppCreate callback, and edit all dataflow, lenses & dashboards to access the objects & fields with {{Variables.Namespace}} prefix.. is there a better/simpler solution? How do developers build templates without namespace & later release in a managed package?
@* CRM Analytics (fka Tableau CRM) *
Apparently I can't add comments to answers, so I had to add another answer to say that other answers didn't really work for me! ;p
Basically, my requirement was to be able to create different 2GP packages with different namespaces (for the purpose of testing, bundling, modular licensing, etc.), where namespace-scoped custom objects and analytics templates can be part of the same package, and the namespaces in the analytics templates had to be dynamic -- meaning, a dataflow or a dashboard in a package with the namespace 'MyNamespace1' could refer to CustomField__c as MyNamespace1__CustomField__c, where as the same dataflow/dashboard in another package with namespace 'MyNamespace2' could refer to the same custom field as MyNamespace2__CustomField__c. The namespace part had to be whatever the namespace happens to be for that packaging.
The Salesforce's design is so inadequate that the "MyNamespace1__" prefix is hardcoded in the template, lens and dashboard files. I was really hoping for a design where either the namespace is specified once in the template to make all field references take up that namespace, or a way for the namespace to be specified as a variable in all these files and its value can be supplied from the sfdx-project.json, or something well-thought-through.
Note that there are also app-create-time variables like ${Apps.MyNamespace__TemplateName.Datasets.MyDataset.FullyQualifiedName} in templates that depend on other templates. Note that again, MyNamespace__ has to be hardcoded in there and that makes it incredibly hard to switch namespaces. Essentially, there's no built-in mechanism to easily switch namespaces (or to deploy without a namespace to scratch orgs) after the template is created!
Just adding "namespace" : "MyNamespace" to template-info.json is insufficient and it does nothing (not to mention, is not required for packaging with a namespace). Note also that "namespace" : "${Org.Namespace}" is completely different -- that's the org's namespace, not to be confused with packaging namespace!!
The other problem with all these namespaces littered in 100s of json files is that it makes it extremely hard to edit the apps post deployment and retrieve the changes to these templates down to repository.
Anyway, I ended up adding a lookup-string to all template, lens and dashboard json files where the namespace should go, and modifying the packaging script to find-and-replace all its occurrences with the actual namespace before packaging. This totally sucks and I wish Salesforce had put a little bit of thought into this (and wish they wrote a better documentation on what's possible and what's not). I wonder how other developers ship their analytics templates in their products!!