Default annotation fields #1585
|
Is there a way to set up default annotations, meaning, whenever I create an item a standard series of annotations is being added, either blank (which would already be very nice) or going a step further, prefilled with a default value (like the creation date, a 'need review' annotation that defaults to 'true',...), and the possibility to define maybe per artifact type different kind of annotations. eg a measures could carry/require different annotations than a table or column |
Replies: 1 comment
|
Hi @JuanSombrero23, There isn't currently a built-in option in TE3 that automatically stamps a set of annotations onto an object the moment it's created, but you can get very close to what you're describing using two features that already exist, and both of them let you vary the annotations per object type. The first is macros. If you save a C# script as a macro, you assign it a context (Measures, Tables, Columns, and so on), and the macro then only appears when you right-click that object type in the TOM Explorer. You can also bind it to a keyboard shortcut, so applying it is a single keystroke right after you create the object. Because it's C#, you can prefill dynamic values such as the creation date, and only add annotations that aren't already there. For example, a macro saved in the Measures context: foreach(var m in Selected.Measures)
{
if(!m.HasAnnotation("CreatedDate"))
m.SetAnnotation("CreatedDate", DateTime.Now.ToString("yyyy-MM-dd"));
if(!m.HasAnnotation("NeedsReview"))
m.SetAnnotation("NeedsReview", "true");
}You would save one macro per context, each with the annotation set that makes sense for that object type, which reflects the idea that measures carry different annotations than tables or columns. The second is the Best Practice Analyzer, which is useful if you want these annotations to be required rather than just available. You scope a BPA rule to an object type, test for the missing annotation, and give the rule a FixExpression so it can apply the value for you, in bulk across the model if needed. As an example, a rule scoped to Measures with the expression Used together, the macro gives you prefilled defaults on demand, and the BPA rule acts as a safety net that catches anything created without them. |
Hi @JuanSombrero23,
There isn't currently a built-in option in TE3 that automatically stamps a set of annotations onto an object the moment it's created, but you can get very close to what you're describing using two features that already exist, and both of them let you vary the annotations per object type.
The first is macros. If you save a C# script as a macro, you assign it a context (Measures, Tables, Columns, and so on), and the macro then only appears when you right-click that object type in the TOM Explorer. You can also bind it to a keyboard shortcut, so applying it is a single keystroke right after you create the object. Because it's C#, you can prefill dynamic values such as the…