SwapAliasWithPrincipalName TI Function – How to Use and Syntax
Have you ever needed to swap the contents of an alias with the primary element name in a TM1 dimension? Well, there is a function that will do exactly this called SwapAliasWithPrincipalName. It does just what it says it will – swap the element’s principal name with the specified alias.
There has never been a mechanism before within TM1 for renaming elements that’s why this is such a big feature. Previously, copying data from one element to another has to be done manually. It is so important to correctly name elements based on codes and identifiers where possible instead of descriptive and often updated names.
For example, Account codes are much preferred to Account Names. This function can fix it for you if, for whatever reason, they were set up using names. For more information on this check out our post titled 3 Cardinal Rules of Sustainable TM1 Development.
I’ve just given it a go, to fix up a small dimension which was using descriptive names as elements. Here are some tips adding to what has been posted here on BiHints.com.
The syntax is:
- Dimension is the name fo the dimension to perform the swap,
- Alias is the name of the alias you will swap with the element IDs
- Switch – This is a numeric variable that must equal 0 for the process to run. So when you’re setting up the TI, set the flag to any value other than 0 to test, then when you’re ready to go, change it to zero.
Method for using SwapAliasWithPrincipalName
- First, the alias you are going to use for the swap isn’t used for anything else at the consolidation level.
- After that, check for any TI Processes you need to update. Then look at the code after the swap has been executed.
- Backup the Server before execution.
- Execute your TI to perform the swap.
- Lastly, restart the Server after you have run the function. After we tested out the function, TI Processes which referenced consolidation elements were producing an “Element not found” error within the TI Process error log. A TM1 Service restart fixed this.
Hope this helps any others working on a similar situation.