Better Formula Editor for Anaplan; A new Chrome/Firefox/Edge Extension

GeorgeDuckett
Regular Contributor

Better Formula Editor for Anaplan; A new Chrome/Firefox/Edge Extension

Hello all!

I have made a Google Chrome and Firefox extension that enhances Anaplan formula editing by using the Monaco editor. This is the editor used by Anaplan's new modelling experience. My extension works with this new experience adding enhancements over and above what Anaplan have done. It also works with the current/old formula editing experience; it's best in the new experience though.

Chrome: https://chrome.google.com/webstore/detail/better-formula-editor-for/lonibgccfehnjjhchfcbdhkaajhobeak
Firefox: https://addons.mozilla.org/en-GB/firefox/addon/better-formula-editor-anaplan/
Edge: https://microsoftedge.microsoft.com/addons/detail/better-formula-editor-for/dkeigmhhjolcnnanpachagca...
(Once added be sure to reload any open anaplan tabs)

Details below:

  • Formula Validation: Various checks are performed on formulas including simple things like ensuring all entities are named / referenced correctly or ensuring the correct data types are used throughout the formula, through to things like checking for dimension miss-matches when referring to line items with different dimensions.
  • Formula Formatting: Provides basic formatting for valid formulas; breaking up IF...THEN....ELSE onto multiple lines with proper indentation.
  • Hover Information: You can hover your mouse over most elements of a formula to get contextual information, for example hovering over line items shows their dimensions and data type and hovering over function names to get information about that function.
  • Quick Fixes: When errors are encountered the extension will allow the user to choose an appropriate fix from a menu which when chosen would make the required changes to the formula automatically.
  • Code Completion: As you are typing the editor will offer auto-complete suggestions for things like line items within the current module, fully qualified line items within other modules, function names etc.
  • Function Information: When completing functions with parentheses you get popup contextual information relating to the parameters of the function together with an explanation of both the function and the parameters.
  • Shortcuts: Standard Monaco editor shortcuts apply. Ctrl-Space; Open code completion. Ctrl-Shift-Space; Open function info (when within function parentheses). Shift-Alt-F for formatting.

The extension is under active development; currently next on the list is intelligent autocomplete suggestions for lookups required when referencing line items with different dimensions. Something like suggesting "LOOKUP: PROP C10 ItemCustomer.P6 Item" when pressing "[" after a relevant line item.

EDIT: The above is now in this extension. Pressing "[" on a line item with dimensions that the current line item doesn't have will prompt it to work out a reasonable suggestion (based on your usage on other formulas) and suggest those LOOKUP/Aggregations as autocompletes.

 

Please let me know what you think; I'm very open to further ideas!

If you like my work you can support me here, via the GitHub sponsorship program.

39 REPLIES 39
GeorgeDuckett
Regular Contributor

I've made some enhancements to this extension. It now supports code formatting, via the context menu (right-click) and via the standard Monaco editor shortcut (Shift-Alt-F). I know this one was requested a while back. I held off of doing this since I read somewhere that it was on Anaplan's road-map, but since it's been a while I figured I may as well add it in.

 

I've also improved handling of the Enter and Escape keys. Now, when code-completion is up and you press Enter it will accept the completion, rather than submitting any formula change to Anaplan. Escape now closes any open editor widgets (such as code completion or function information) rather than stopping editing the formula.

chenjack.sonos
Certified Master Anaplanner

Thanks @GeorgeDuckett! I just downloaded it and it looks fantastic - will share feedback, if any, as I use it!

M.Kierepka
Certified Master Anaplanner

Hi @GeorgeDuckett,

 

Wow, it's really good! Nice functionalities, extremely helpful, and at least for now I have not met any bugs.

 

Idea from me: Thanks to formula autocompletion and function information, it's fantastic when you don't remember order of arguments or how some function should be used. And in my opinion, all would benefit even more if you could add:

  • “Be cautious” — warning, maybe in form of underline (not red, but yellow/orange), for functions like TEXTLIST, RANK, SELECT:, FINDITEM, to warn users that function like this can cause performance or maintenance problems.
  • “More info” — just like you have link to the Anapedia page for highlighted function, maybe you can add some link to Planual about it? (TBH, such links should be added by Anaplan to Anapledia for some functions like SELECT: or TEXTLIST…)

Also, as you released extension for Chrome, it should work and be installable on any browser that use Blink browser engine (so not only Google Chrome, but also Microsoft Edge, Vivaldi and Opera). However, I am using Mozilla Firefox, which uses different engine, but still your extensions should work there, even though currently it cannot be installed, as it's not in official Mozilla Firefox addons store. So I am using developer mode for your plugin, and tried to adapt it, so it can work under Firefox, and… it worked. So I'd be really happy if you could also officially release your plugin for Firefox, so others can use it as well - the only thing I needed to adjust is manifest.json (I am pasting content of the one that worked for me, feel free to change/update it):

 

{
	"browser_specific_settings": {
		"gecko": {
		  "id": "georgeduckett@anaplan.com",
		  "strict_min_version": "90.0"
		}
	},
   "content_scripts": [ {
      "all_frames": true,
      "js": [ "/dist/content-script.js" ],
      "matches": [ "https://*.app.anaplan.com/*" ],
      "run_at": "document_end"
   } ],
   "description": "This extension enhances Anaplan formula editing in several ways; providing code completion, hover info and validity checks.",
   "icons": {
      "128": "logo.drawio.png"
   },
   "manifest_version": 2,
   "name": "Better Formula Editor for Anaplan",
   "version": "1.1.0",
   "web_accessible_resources": ["dist/*"] 
}

 

GeorgeDuckett
Regular Contributor

Hi @M.Kierepka,

Thanks for the interest; glad you're finding it so useful!

Those are all really interesting ideas and something I could potentially look to add if there's enough interest. I'm not 100% sure if I want to add warnings for things that are valid (but possibly should be avoided) when I don't have an easy way to ignore them. I want to avoid my extension having options, although I'm not opposed to the idea, but even if I added an option to ignore/hide warnings that still might not help though, as there wouldn't be a way of ignoring one warning without ignoring all of them.

Re. the idea about linking to the Planual is good, but would be fairly timeconsuming. Currently to get information about Anaplan functions I'm parsing their documentation automatically since most pages are a consistent format, but for the Planual that isn't the case. Also, most of the topics don't directly relate to a single formula syntax or function; they're general advice so I'm not too sure where any links or text would appear.

Re. a firefox extension I'm working on that, but it's not quite as straightforward as I'd hoped. When publishing the addon there are limits on the size of any one javascript file included. I've eventually gotten around this, but have had to drop support for the old/current modelling UI since that meant I had to include the code for the Monaco editor, which is too large. This meant I had to split the build process to create separate packages for Chrome and Firefox. For Firefox you also have to submit the source code and instructions to run a build, so I've got to make sure I've got clear instructions there too. It is definitely on the list though, and I'm hoping to have something by the end of the week.

GeorgeDuckett
Regular Contributor

@M.Kierepka I've created a version of my extension for the Firefox Addin store, so you should be able to use that version. I was also able to keep support for the old modelling experience in the end even with Firefox's restrictions, although I'd still recommend the new one. I also added a version specific to Edge too for good measure.

The firefox addon page is here: https://addons.mozilla.org/en-GB/firefox/addon/better-formula-editor-anaplan/

M.Kierepka
Certified Master Anaplanner

Wow, I really appreciate all the work you have done! I downloaded it from Mozilla's page, tested briefly, works like charm 👍
I think more and more Anaplanners use New Modelling Experience (including myself), but still thank you for supporting old one.
GeorgeDuckett
Regular Contributor

No problem. It's a fun little side-project! Yeah, I think the new experience is much better than the old. Was a fun little challenge learning about various bits and pieces to make the firefox addin work with the old too though.

Misbah
Moderator

@M.Kierepka @GeorgeDuckett @chenjack.sonos 

 

Does it work on Mac as well? I just added this extension to the chrome and it didn't change anything

GeorgeDuckett
Regular Contributor

@Misbah That's interesting. I don't have a mac to test with, but my understanding is chrome extensions should work the same regardless of operating system. Did you try it in the new modelling experience? Note that visually it won't change anything until you start to edit a formula, at which point it should do the things detailed in the YouTube video; auto complete line items / modules / function names etc.