Deltek Cobra’s API (Application Programmers Interface) provides the capability to interact with internal processes from outside the program. This gives users the ability to run simple scripts that trigger Cobra processes without having to run the program and navigate the interface.
Here we give you an overview of the Deltek Cobra API and some useful pointers that will save you some time and possibly frustration in setting up a working batch script to handle some of your common monthly update processes.
Overview
Starting with the basics, the Deltek Cobra API is a separate executable that resides in the Cobra installation directory and processes input by reading a plain text file containing specific commands. For example, you can run a batch process that backs up a project, then advances the calendar, runs the update integration process and calculates earned value; all while you’re off getting that second cup of coffee for the morning.
So automating many of the repetitive processes you perform regularly is quite within your reach by creating a simple text file. The trick is getting the correct commands into the text file and then executing the batch file; each of which requires some careful setup.
The Cobra.API.exe program can be run from either a command line using the Windows Command window or better still, by creating a Windows shortcut. The syntax is as follows:
C:\Program Files (x86)\Deltek\Cobra 5>cobra.api.exe script:”c:\deltek\runev.txt”
Make careful note of the use of quotes after the script parameter. You may or may not need these quotes depending on your system; but best to be safe and include them in your path. The Running a Script File example in the Cobra online help doesn’t show the quotes around the path to the .txt file, so you may spend some time wondering why your script is being ignored.
If the script runs correctly, you should see a brief dialog appear showing the progress of the process.
If the API batch process failed for some reason, you won’t be notified, you just won’t see the above dialog appear.
Batch.Api.log
If you’re ever wondering what happened when your batch file ran (or didn’t as the case may be) then go to the Deltek\Logs directory in your Documents folder and open a file called Batch.Api.log. This gives you a description of the batch process and reports any errors or warnings that may have occurred.
The most recent events are recorded at the bottom of the log, so scroll down to check out your situation.
In this example, the log is reporting that it can’t login to Cobra. Two reasons for this are that (1.) You’re already logged in to the Cobra application or (2.) your setup requires that you use an additional parameter in the command line to indicate your required login. The syntax for this parameter is as follows:
user:sysadmin/password.
Place this parameter after the end of the script: parameter if you are seeing the ‘[Error] Unable to login” message in your Batch.Api.log.
Creating a Batch Script Windows Shortcut
Anything you can run from a Windows Command window can also be called using a Windows Shortcut. Here are the steps for our previous example.
1. Right-click on a clear area of your Windows Desktop.
2. From the menu choose the New option and select Shortcut from the resulting submenu.
3. Use the Browse… button to locate the Cobra.Api.exe file; typically in the [C:\Program Files (x86)\Deltek\Cobra 5] installation directory.
4. YOU’RE NOT DONE with this field just yet! You now need to add the Script and User parameters to this path. When you’re done it will look something like the following:
5. Click Next and then enter a name for your shortcut.
6. Hit the Finish button and you’re ready to rock-n-roll with a batch process any time the shortcut is clicked.
The Batch Scripts
Moving on now to the contents of the batch scripts, let’s look at a good example of a script that runs the integration configuration for a project data update.
This example was unapologetically copied directly out of the Deltek Cobra online help file and pasted into Notepad; a method I’d recommend to anyone starting to build a batch file. Just go into the Cobra help system and type the word ‘batch’ in the search field of the Index tab. You’ll see a complete list of the batch processes you can run, with a detailed explanation for each tag therein and a helpful sample at the bottom. Thus I’m not going to attempt to republish this information here, rather just show you how to get at it.
Deltek Cobra allows up to 999 processes included in a single batch file. You just need to give each one a unique process ID. This allows you to automate most of your common actions such as those used for every new reporting period. It does take a little preplanning to pull this off, particularly if you’re thinking of using this for project integration, as your I/W configurations need to be correct and pointing to consistently named transaction files. Other than that, the tag syntax is pretty self-explanatory and you should be able to get started with this method of Cobra management fairly easily.
Well there you have it folks; a good starting point for anyone looking to make their job a little quicker and easier we hope. If you have any comments or questions about this blog, feel free to email us.
To read more Deltek Cobra articles click here