Main Question :
I have created various custom functions that I frequently use. I would like to store them in a repository somewhere and call them whenever necessary. I know that I can save all those functions in an Excel file and save it in OneDrive. But I would like to save them somewhere I can edit and share them easily like GitHub.
And finally, if it is possible, can we make a private repository? If i want few of my functions to be shared privately, can I protect/lock them using a password?
Helpful Resources:
Understanding the following probably might be helpful in answering this.
Resource 1:
There is a function called #shared in PowerQuery which lists down all the functions available and their respective description. You can know more about it at the following post.
I think understanding how does this function (#shared) work and Where is this information being extracted from will be helpful in answering My main question above. Which is basically, how can I make something like this for my custom functions?
Resource 2:
One possible help for this question would be an existing repository in Github by Hugoberry.
Note:
I'm not a coder, but I'm comfortable in reading/understanding codes.
I don't understand Github very clearly.
Edit 1:
For those who are looking for an answer to this question, the answer provided by Nacho works for creating a function with Manual Entry(Text/Number) inputs.
It does not work for functions that refer to a table/parameter.
After taking a long path on this I solved it. Below are the steps to do this:
First create a .pq file with Notepad like this example and push it to GitHub:
let
TextAsNumber = (valor as number) =>
let
Mostra = "The number is: " & Text.From(valor)
in
Mostra
in
TextAsNumber
Then go to the file in github and click on "Raw"
Copy the URL. Open Power Bi Desktop edit queries. Get Data from blank query and paste this:
= Expression.Evaluate(Text.FromBinary(Web.Contents("https://raw.githubusercontent.com/ibarrau/PowerBi-code/master/PowerQuery/PQFun.pq")),#shared)
That code will create you the function from repository.
Note: The same thing can be made with local path too, just replace Web by File on "Contents". Like so:
= Expression.Evaluate(Text.FromBinary(File.Contents("C:\Users\username\Documents\Folder\Sub-Folder\PQFun.pq")),#shared)
Hope this helps you to manage better the custom function repository.
PS: I'm not sure if you are going to be able to refresh in Service.
Related
Recently, I've been working with application insights and building up my queries and understanding. One of the features that I would expect is to define functions outside of the scope of a particular kusto script/query with the intention that the function can be reused from other scripts/queries.
When I started working with it, I had noticed a menu item under the sources that was labeled fx functions and had assumed that this is where I could eventually add my functions. Initially, I saw no UI path to create one and I thought this was due to authorization policies. As I'm now much more comfortable with the Kusto language, I want to break my big scripts into smaller ones but I can't.
I've checked with a private account, where I'm full owner, if I could add one but there no UI path as well. I spoke with our Azure configurators and he as an owner can't find a UI path as well. This doesn't seem to be a result of limited authorization. I've google this and I can't find anything. I've the documentation and there is not mention.
Anyone knows what this is and if it represents a custom functions library how can it be modified? How would you reference it?
Update 1
From an answer provided by #ivan-yang, it seems that I missed this when trying out with my personal account. Apparently, you can save a script as
A query
Private
Shared
A function
When saving as a function, the system creates a reference in the shared queries but with a different icon.
Update:
Correction, I can update the function. When a function and a shared query exist with the same name, then there is a problem. Once I renamed the shared query to something else, I could overwrite the function.
In the application insights -> Logs, in the editor field, you can write a query, then click save -> in the popup window, provide a name like f1, then save as Function. Then you can see the the new function f1 in the "fx Functions":
And as per my test, if you define a custom function and save it, there is no chance to modify it.
Regarding how to reference it, you can use the function like requests / traces, like using union / filter etc.
I want to define a new template called "product".
This template calls an external service and retrieves the information about that specific product. That is easily done with a custom plugin that access the product information. Information on how to do that has been found here.
However, I would like that the URL of the page would be something like:
/product/<id>/<seo-friendly-description>
So I can retrieve in the Twig template both <id> and <seo-friendly-description> which will be used later to retrieve the specific product information.
I have tried to find something that could help in the documentation, without success. Could someone either point me to the right doc section or highlight the basic steps that shall be achieved so I can start solving this issue?
Just in case it helps, I am trying to find something similar to how bottle or other web frameworks work:
#route('/hello/<name>')
def greet(name):
return 'Hello ' + name
I've been building a family recipebook into my own website and I've been working through a similar problem. I haven't quite worked out all the kinks, but my solution is mostly working if you want to checkout my github repo.
In short, you need the plugin to watch what the active route is. If the route matches, you then create the page and populate it using your plugin data.
I haven't quite figured out how to get the active page to highlight in the navigation menu for generated pages, but you might still find this solution helpful.
I need to write a plugin that needs to create table in database and some setting from installation form. I can easily create form but I have difficulty to run the script after installation to read options and create table. Is it possible at all to run such simple script or maybe you need to create everything like for example models, vehicles and so on?
I would appreciate if anyone could give me directions how to do it. Modx documentation is not clear about this and https://github.com/splittingred/Doodles/tree/production sample repo contains multiple elements I'm not familiar with and I believe don't need at all
Typically you'd use a resolver to run code after the install.
While in the question comments the setup options are discussed, the package attributes there are actually executed to generate the setup options form, not to process the results.
The docs are a tad dated (mostly the screenshots), but Creating a 3rd party build script explains the different parts of a build script, and what they're for, with a fair bit of examples.
The piece you're looking for is this:
$vehicle->resolve('php',array(
'source' => $sources['resolvers'] . 'setupoptions.resolver.php',
));
You'll need to have a $vehicle (perhaps from a category or other object you're adding to the build) and the file in the provided location. Inside the resolver file you can use $object->xpdo as an instance of the modX class to do your thing.
I have a request form I'm working on, wherein different departemnts need to be able to update it. To minimize overlap and lost changes I'd like to be able to submit data from the new form to different lists, but I cannot find a way to do this.
Does anyone have any experience trying to do anything similar?
If you're familiar with JQuery andSPServices I could envisage a way to do this.
In the EditForm.aspx, add the JQuery and SPServices libraries. using the $.(document).Ready function, I'd do a quick item update with the SPServices and just copy a column with the same data, so in effect no change looks to have taken place. I'd add in the edit comments something like "Pseduo checkout to [name], [date_time]".
Then allow the user to edit the form as normal but in the code you've added, you trap the PreSave Action and check that the person trying to do the save is the same as the last modified - if it is, save as normal, otherwise, return false on the PreSave and it will be denied. When you actually allow the save, set the edit comments to something sensible.
To complete this, check before doing the pseudo checkout, that the last comments don't contain the psuedo checkout phrase so that you can prevent anyone opening/editing the form whilst somebody else is in the middle of an edit.
This gives a cheap and relatievly easy to implement Check-In/Check-Out for a list. Not perfect of course but should work well in most scenarios (not in datasheet though, so you might need to prevent that type of edit).
If you have two lists would you not then have the problem of potentially two requests for the same thing?
Does none of the version control options for the list solve the problem of potentially multiple concurrent editors?
While SPService is certainly a solution, but you will have to build a UI of ur own.
Try writing a event receiver, which can copy over item to another list as soon as it is created.
It will be nice if you can tell why you really want to have a copy of item in another list
i.e. Auditing purpose etc. , you can get a perfect solution for this in Forum
I noticed that sitecore has the option of exporting users in an Excel format.
I need to have similar functionality for exporting 'participations', (a users can enlist to take part in an 'event', and if their entry is approved via a sitecore workflow, a 'participation' item is created in the content tree)
Since mostly everything in Sitecore is in essence based on items, and I want to export items to Excel, my question is - what are some of the best ways of doing this?
Questions:
Is there a way to re-use this functionality for regular items?
Would it be a good idea to create a custom admin page (any tips on doing this?) which has some custom code that reads the items from the database using the API?
are there sitecore plugins/shared source projects that can help me achieve this?
Or does anyone have a better idea? - would it be better to just store the participations in SQL? I'm mostly doing it this way because I want to make use of the 'free' functionality offers, for example workflow, but if that leads to me using anti-patterns please shoot me ;)
Link is different now: https://marketplace.sitecore.net/en/Modules/Advanced_System_Reporter.aspx
P.S. Couldn't leave a comment to original answer as I don't have enough reputation. Oh well :)
Found a most excellent shared source module which does exactly this (and much more)!
Basically it allows you to configure (and easily extend, if you need to) any kind of table based report on 'items'.
The report module shows up as an application in the sitecore menu (like the user manager tool) and comes with features such as xml,csv, xls export. It's also really easy to set up, once you get the hang of it.
http://trac.sitecore.net/AdvancedSystemReporter