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/dkeigmhhjolcnnanpachagcaggjgmacl
(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 shows 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.

«13

Answers

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

  • 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/*"] 
    }

     

  • 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.

  • @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/

  • 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.
  • 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.

  • @M.Kierepka @GeorgeDuckett @jackcplanning 

     

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

  • @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.

  • @GeorgeDuckett 

     

    That was my assumption as well that it should work on chrome no matter what the OS is but I don't think it is working for me.

     

    Yes, I am trying it in formula editor of NUX

  • @GeorgeDuckett 

     

    Worked now! Had to re launch chrome and re login anaplan.

    Thanks,

    Misbah
    Miz Logix

  • @Misbah Ahh ok, good, glad you got it sorted. Yeah, since when navigating around Anaplan in the new modelling experience it keeps you on the same page after installing the extension you'd need to navigate somewhere else (like the log in screen) then back again, or reload the tab you're on. I'll add that to the initial post.

  • Hi George,

     

    Thanks for sharing this extension with all the community! I've just downloaded it, so I was not able to use it a lot yet, but it looks really good!

     

    Are you planning to add indentation for the IF THEN clauses?

     

    Best regards,

     

    Ramiro

  • Hi @rodriguezramiro, thanks for the interest!

    Yeah, it does do formula formatting / IF..THEN indentation. It's available via a right-click menu or using the shortcut Shift-Alt-F. I know it's something on Anaplan's list to be included as standard but I got fed up waiting so added it myself for now.

  • Thanks for your quick answer!

     

    I was not able to find any right click menu, but it works with the shortcut. Nevertheless, when I edit an existing formula and activate the indentation, all references to line items outside the module that I'm in are lost (I've attached 2 screenshots as an example). Is this only happening to me or is it a known issue?

  • The right-click menu is only available when editing the formula. You should be able to right-click anywhere within the formula window to get the context menu up.
    I've replicated your issue and got a fix for version 1.2.2. I've published this, but they take a short amount of time to get loaded into the browsers' extension stores.
  • Thanks for trying to fix it so quickly. I've downloaded the latest version (it said it was published today), but now when I activate the "Format Document" functionality, it does nothing (no references to other modules are lost, but no indentation is shown). I've tried closing the browser and re-launching it, but I had the same result.

  • Hmm, ok, I'll take a look later today or early tomorrow.

  • Got it sorted. Sorry about that!
  • It works! Thank you so much! This is great! Now it will be easier to convince my team to start using the New Model Builder Experience!


  • @GeorgeDuckett wrote:

    @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/vavada.net.ua/ 


    hello, I don't see the setup page for Chrome. thanks. Useful extension!

     

  • Hi @NatalyaOnek, Sorry, not too sure what you mean by setup page. Once you install the chrome extension and reload any open Anaplan pages you have it should just work. There isn't any setup of the extension that needs to be done. There isn't any options page to configure either.

  • Hello Geroge,

     

    Your editor would be really helpful for me but I have 2 issues : 

    I got an error message as followed 

    christinemollard_0-1647357039347.png

    and when I finally got the extension installed, it seems that I have colours for the formulas but no tabulation or line break.

    christinemollard_1-1647357309062.png

     

    Could you please help me ?

    Thank you in advance,

  • Hi Christine,

    Not sure about that first message. Possibly you had Anaplan open when you installed the extension?

    The formula formatting isn't automatic. When in edit mode you can right click the formula and choose "Format Document" which will do that. As @rodriguezramiro says, you can also use the built-in shortcut Alt+Shift+F.

  • Hi @christine.mollard,

    Did you try pressing Alt+Shift+F when editing the formula?

    Regards,

    Ramiro
  • Perfect !! Many thanks !

  • Thank you for your quick answer, I didn't know about the Alt+Shift+F

    This is really appreciated 🙂

     

  • I've now just released version 2 of this extension. As well as numerous minor bug fixes and enhancements it adds autocomplete for missing dimension LOOKUPs/aggregations. Pressing "[" after a line item with different dimensions to the formula's line items will prompt it to work out what you've used in other formulas and suggest those.

  • Going to try it out, my team was looking for a replacement of A+ for Anaplan. Is this project on GitHub? Was thinking of making this myself to fool around, curious what the code looks like!

    @GeorgeDuckett 

  • Hi @Anaplant, it's closed-source for now, but I might open source it at some point in the future.