Where is the C# Script File Stored and What name should be given to the file? #1022
Replies: 10 comments
-
@Kealkil4 Not sure what is the official recommendation but I like saving the script to a folder (shared folder location like OneDrive if you have multiple people working on Power BI). Not sure where custom actions are saved and if they could be easily shared with others. |
Beta Was this translation helpful? Give feedback.
-
Thanks for the response ... I will try to follow your advice. I find myself looking at long presentations on the Tabular Editor given by people who are very familiar with the product. Daniel needs to realise that a lot of the people who will subscribe to the product will be novices in terms of its usage. I know exactly what I want TE3 to do for me ... but getting it set up properly and having a comprehensive tutorial that would take you through the features in a structured manner would be a great help. |
Beta Was this translation helpful? Give feedback.
-
Hi @Kealkil4 However, if you have a number of scripts that you reuse often, consider saving them as macros. This way, they are automatically loaded (and even integrated in Tabular Editor's context menus) whenever you launch the tool. To save a script as a macro, choose the C# Script > Save as Macro... menu option: In the dialog that pops up, choose a name for your macro (you can use \ (backslash) to group macros into "folders"), provide an optional description as a tooltip, and select which types of objects the macro should be enabled for. Once the macro is saved, you can see that it is integrated directly in the context menu of the TOM Explorer. So in the example above, if I right-click on a partition, I can execute the script directly from the context menu: To manage the macros you have previously saved, go to the "Macros" view (View > Macros): From here, you can delete a macro by clicking the red "x", or you can double-click to bring up the script for a macro. Hope this helps. |
Beta Was this translation helpful? Give feedback.
-
It would be very helpful to have the macros saved as .csx files in a "CustomActions" folder instead of the MacroActions.json file. This would allow much more collaboration and work with vcs. |
Beta Was this translation helpful? Give feedback.
-
@otykier the main issue I see with macros is that it does not support multiple people (team development) sharing the same macro. If I change a macro, I want other workers in my group to invoke the latest version I updated. is there a way to implement macros in a way that supports collaboration? |
Beta Was this translation helpful? Give feedback.
-
This is a challenging issue from a security perspective, as we cannot allow users to inadvertently execute C# code that they did not author. Potentially, a C# script could contain malicious code. If we are talking about putting the macro definitions in separate files instead of one big json file with all macros, then that's certainly doable, but we still have to keep the files in a location where only the current Windows user (or a machine admin) has write access - this is exactly the purpose of the In other words, if you want to load the macros from a VCS, you would have to create a script or something like that, which loads the newest version of the macros from VCS, placing the files in the @DavidmSalm and @dpesante what are your thoughts on this? Thanks! |
Beta Was this translation helpful? Give feedback.
-
I'm trying to get the github desktop in my corporate laptop, to keep in sync my own macros -- I hope it goes nice |
Beta Was this translation helpful? Give feedback.
-
For my purposes that definitely works. We have our entire team using git and so individual developers can update their own scripts to the latest in the repository. The primary goal is being able to use git at the line level instead of the script level which would make review and approval much easier within pull requests. P.S. Sorry for the late reply. |
Beta Was this translation helpful? Give feedback.
-
Was just wanting to do exactly this: Save my macros to GIT. On the security point, is it any different to downloading a repo to my git folder in my documents and opening VS Code and hitting run? The emphasis has always been on the end user to review the code before running... I don't think the folder where the files is being saved to should be restricted to localappdata... BTW, I like the idea from @bernatagulloesbrina to have separate collections, i.e. a personal collection and a corporate collection. |
Beta Was this translation helpful? Give feedback.
-
Further to this, you could implement some commented structure in the script files to capture the settings: // Tabular Editor C# Script
// ------------------------
// Name: Macros\Launch\Analyze In Excel
// Description:
// Context: Model
// Context Hidden: false
// Enabled: true
// ------------------------
// https://github.com/TabularEditor/TabularEditor3/issues/249#issuecomment-939848828
// Works with version 1.1.3 when MSOLAP isn't separately installed as per Analyze In Excel warning.
#r "Microsoft.AnalysisServices.Core.dll"
using System.Diagnostics;
var connectionInfo = Model.Database.TOMDatabase.Server.ConnectionInfo;
var server = "";
var database = "";
if (connectionInfo.Port == null)
{
server = connectionInfo.Server;
database = Model.Database.Name;
}
else
{
server = connectionInfo.Server + ":" + connectionInfo.Port;
database = Model.Database.ID;
}
Process.Start("C:\\Program Files (x86)\\Sqlbi\\Analyze in Excel for Power BI Desktop\\AnalyzeInExcel.exe", "--server=\"" + server + "\" --database=\"" + database + "\" --telemetry"); And maybe file names like:
|
Beta Was this translation helpful? Give feedback.
-
I wish to add Useful Script Snippets to TE3.
Where should the script file be located so that it is automatically picked up on Opening Tabular Editor? And what name should be given to .csx(?) file?
I have managed to paste in the first of the "Useful Script Snippets" for creating Measures for selected objects.
When I go to save the script .. it is suggesting the "Documents" Folder and a name of "C# Script 1 .csx"
=====
Or maybe I should be saving the script as Custom Action.
Can't find directions on how to do this.
I'm not a programmer, but I need the productivity that comes with using / re-using these scripts.
Would appreciate any feedback.
Thanks.
Beta Was this translation helpful? Give feedback.
All reactions