Mar 2, 2018
Trigger an action when a value is updated in a TM1 cube
TM1py v1.0 introduces a new exciting feature: Delta request for transaction log. It means that each time a value is updated in a TM1 cube, TM1py is able to trigger an action such as running a TM1 process or sending this new value to an other cube…
Synchronizing data from two different TM1 instances
For example, if you want to synchronize the data of the same cube which is in two different TM1 instances. Each time a value is updated in this cube, TM1py could send this value into the other TM1 instance using the TM1 REST API.
How does it work?
TM1py v1 includes a new sample Transactionlog delta requests which will show you how to capture a transaction. This new sample will display the intersection of the cube where the data is updated with the old and new value into the console.
To run this sample, you just need to update at the top the TM1 configuration parameters (address, port…) and the cube you want to track:
After running the script, TM1py will run in the background and each time a value is updated in the Retail cube, it is going to print into the console. For example, here we input 4000 in the Retail cube:
Show the transaction log into a console
For every new input, a new line in the console will be created:
Send the transaction log into a text file
Instead of a console you could choose to send the value into a text file by replacing:
print(entry["Tuple"], entry["OldValue"], entry["NewValue"])
with
intersection = ";".join(entry["Tuple"])oldValue = str(entry["OldValue"])newValue = str(entry["NewValue"])info = intersection + ";" + oldValue + ";" + newValuewith open('output.csv', 'a') as file: print(info, file=file)
The TM1py script will look like this:
After updating some values in the Retail cube, you will see that TM1py has populated the output.csv file with the equivalent of the TM1 Transaction log: