Apr 4, 2018

Create your own snippets

Arc helps you develop higher quality TM1/Planning Analytics applications faster. Arc is full of features which will save you lots of time, one of them is the snippets.

When you hit CTRL + Space in either a process or a rule, a drop-down appears which gives you access to:

  • All your variables defined in the TM1 process.
  • All your TM1 processes.
  • All TM1/Planning Analytics functions.
  • A lot of battle tested code (snippets).

The list is constantly updated. If you create a new TM1 process, it will appear in the dropdown list, in the example below we add the new process Dim.Employee.UpdateEmployee:

How to find the complete list of snippets

The snippets are located in the snippets folder inside the Arc folder. You will then find one folder for the process and one for the rule. If you go to the process folder you will find the default.hjson. The default.hjson file inside the process folder contains the list of all default snippets that you will see when editing a process:

How to create your own snippets

To add your own snippets, just create a new file. Let’s call it my-snippets.hjson. You can create it from scratch or copy the default.json file and keep just the first snippet as template to start with:

A snippet has two main parts:

  • value is what you see in auto complete.
  • snippet is the content inserted.

The file .hjson supports next line character. So you can just copy paste code from your process into the snippet:

Once your file is saved, you just need to refresh the browser, do not forget to clear the cache (SHIFT+F5) for Arc to get your new snippets. Once in the process hit CTRL + SPACE in a process and type @my, you should have access to your new snippet:

Using placeholders

The placeholders are used to update blocks of code, example: ${1:condition}:

If you want the code to be updated in multiple locations, you need to use the same placeholder number, as the example below:

{    value: @My Hierarchy Create or Unwind    snippet:      '''    #Create Hierarchy    If(HierarchyExists(${1:sDim}, ${2:sHierarchy}) = 0);      HierarchyCreate(${1:sDim}, ${2:sHierarchy});    Else;        EXECUTEPROCESS('}bedrock.hier.unwind',        'pLogOutput', 0,        'pDim', ${1:sDim},        'pHier', ${2:sHierarchy},        'pConsol', '*',        'pRecursive', 1,        'pDelim', '&'        );    EndIf;        HierarchyElementInsert(${1:sDim}, ${2:sHierarchy}, '', ${3:sTopConso}, 'S');          '''  }

${1:sDim} is used in multiple location, when using this snippet you will see that all ${1:sDim} placeholders will be updated at the same time:

Related content

Loading related content