The TACTIC Script editor allows for Javascript and Python based scripts to be written and stored in a "custom script" SObject. These scripts harness the power of Javascript in the web browser along with the power of the Python TACTIC Client API. They can be structured to run on a general execution, by a trigger or, they can be attached to a button to execute for a specific SObject.
One of the main benefits with using this method of custom scripting in TACTIC is that the script writer does not have to have direct access to the server's file system.
The TacticServerStub.log() method has a parameter named level. The argument for level can be one of the following keywords:
level | critical | error | warning | info | debug - arbitrary debug level category |
The TacticServerStub.log() method can be used as follows:
server = TacticServerStub.get() server.log('debug')
Indicating the debug level argument provides the convenience to sort the Debug Log table by the level of the message. This table can be found under:
Admin Views -> Server -> Debug Log
In the My Admin -> User Preferences, these 5 keywords are used to control what appears in the Javascript Output Client Log when the following is run: log.critical('my_message'). If your User Preference is set to critical, only log.critical() messages show up in the log. Likewise, log.error(), log.warning(), log.info(), and log.debug(), these messages will print to that JS Output Client Log only if the appropriate level is set.
Example 1: Insert A New sObject
// INSERT A NEW SOBJECT var server = TacticServerStub.get(); var code = "model_crane"; var asset_name = "model crane"; var description = "A model of a crane."; var search_type = "toyrus/lego_set"; var project = "toyrus"; var data = { 'code': code, 'name': asset_name, 'description': description }; var search_key = server.build_search_key(search_type, code, project); var result = server.insert(search_type, data); console.log(result);
Results after insert:
Example 2: Get An sObject by Its Search Key
// GET BY SEARCH_KEY var server = TacticServerStub.get(); var search_type = "toyrus/lego_set"; var code = "model_crane"; var project = "toyrus"; var search_key = server.build_search_key(search_type, code, project); var result = server.get_by_search_key(search_key); alert(result.description); console.log(result);
Results after get_by_search_key():
Example 3: Update An Existing sObject
// UPDATE EXISTING SOBJECT var server = TacticServerStub.get(); var code = "model_crane"; var project = "toyrus"; var asset_name = "model crane"; var description = "Revised description of a crane."; var search_type = "toyrus/lego_set"; var data = { 'code': code, 'name': asset_name, 'description': description }; var search_key = server.build_search_key(search_type, code, project); var result = server.update(search_key, data); console.log(result);
Results after update:
Example 4: Retire An Existing sObject
// RETIRE AN EXISTING OBJECT var server = TacticServerStub.get(); var search_type = "toyrus/lego_set"; var code = "model_crane"; var project = "toyrus"; var search_key = server.build_search_key(search_type, code, project); var results = server.retire_sobject(search_key); console.log(result);
Results after retire: