Siebel Spooler in C#

A comment from Ranjith prompted me to dig out an old application that I wrote a long while back. It uses the Siebel Mobile Web Client Automation Server control to allow you to dynamically enable and disable spooling from the active Dedicated Web Client session.

SQL Tagging, as provided in Siebel 8, kind of negates some of the need for this type of tool as it’s now pretty easy to see where dodgy SQL is being generated. However, it’s still useful for determining memory leak type issues and the source will also go some way to demonstrating how to use COM from within C# to attach to a running Dedicated Web Client instance.

It really is as simple as including a reference to siebel.exe and then using:

TWSiebelLib.SiebelWebApplication siebelApp = new TWSiebelLib.SiebelWebApplication();

The tool can be found here and the full source code here. You’ll need to run the tool ‘As Administrator’ in order to connect to the Siebel application. You’ll need to do the same with the Visual Studio shortcut too, if you wish to debug the code. Finally, you’ll need to download the Microsoft API Code Pack for Visual Studio if you want to compile the code.

As usual, the source is being distributed under the GNU General Public License.

Please feel free to comment below.

VN:F [1.9.14_1148]
Rating: 0.0/10 (0 votes cast)

Siebel Code Challenge – #3

UPDATED: My old friend Terrence was the first to spot the ‘deliberate’ mistake. Property sets can be your friend – they offer a persistent and flexible mechanism to move pairs of name, value strings across entities. However, the Siebel compiler is unable to spot situations where not all control paths set an expected value on the output property set. In this case, we were seeing occasional errors in our logs with the text “Argument ‘x’ in step ‘y’ is not correctly initialized or does not return valid data”. This is because the code was failing to set an expected output value which caused the Workflow to throw an exception and prevent a critical business process from executing correctly.

Another anomaly for you to decipher – an easy one again today! Once more, I must emphasise that these are examples of code and configuration that I’ve found in live, Production Siebel environments. I’m not posting these to shame anybody (well, maybe a little) but to show how the simplest mistake or ommission can comprimise the functionality and data quality within Siebel.

Virtual prize for the first to point out the obvious mistake!

Note that this function forms part of a Business Service that is invoked from a Workflow Process Step. The Process uses the output to determine what to do next.

function CodeChallenge3(Inputs, Outputs)
{
  // Declare variables
  var boContact, bcContact;

  try
  {
    // Instantiate new BC instance
    boContact = TheApplication().GetBusObject("Contact");
    bcContact = boContact.GetBusComp("Contact");

    with (bcContact)
    {
      // Create query context
      ClearToQuery();
      SetViewMode(AllView);
      SetSearchSpec("Id", Inputs.GetProperty("ContactId"));
      ExecuteQuery(ForwardOnly);

      // Record is found
      if (FirstRecord())
      {
        Outputs.SetProperty("Found", "true");
      }
    }
  }
  catch(e)
  {
    // Call the custom LogError function to write error to error log
    LogError("Woops, an error has occurred!");
  }
  finally
  {
    // Destroy objects
    bcContact = null;
    boContact = null;
  }
}

Answers on a postcard or post in the comments block below!

VN:F [1.9.14_1148]
Rating: 0.0/10 (0 votes cast)

Siebel COM – a simple LOV loader tool

In keeping with my theme of developing useful tools that work with my day to day Siebel tasks, I’ve decided to make available the code to a really useful, and simple, Excel based tool. It’s a spreadsheet that allows you to bulk load and update LOV values in a Siebel environment.

The tool uses the Siebel COM Data Control, which allows the code to connect directly to the Siebel object manager via SISNAPI – there is no requirement to have a Dedicated Web Client running in order to use the functionality. You’ll need a Dedicated Web Client installed in order for the spreadsheet to reference the appropriate DLL and you’ll need to have enabled the COM Data Server as part of the Siebel Server installation process. You can control to which environment you connect via the parameters on the main page.

The code to connect and close the connection to Siebel may prove useful to those of you looking to build similar tools of your own. You can also use what’s there to see how to process spreadsheet records to import via the Siebel objects and how to manipulate Siebel objects based on rows in the spreadsheet.

PLEASE NOTE that I’m making this code available out of the kindness of my own heart, under the GNU General Public License. I can not and will not be held responsible for any loss or damage caused by incorrect use of the tools that I provide free of charge. Pointed at the wrong environment, the tool gives you power to make significant and potentially unwanted changes to data. Be warned!

You can download it here and feedback any comments or suggestions via the comments box below.

VN:F [1.9.14_1148]
Rating: 10.0/10 (1 vote cast)

Siebel Code Challenge – #2

UPDATED: Okay, Rick wins this one with an early correct answer! Definitely an easy one but I was surprised to come across this. Never underestimate ‘schoolboy errors’ creeping in to code! I’ve seen plenty of occurrences of using the assignment operator (=) in place of the equality operator (==) but this was the first time I’d come across it the other way around! Well done to all who spotted the mistake and to everyone who identified other issues in the code. Note that the field was Force Active, I just forgot to tell you. ;) Virtual pints all round, I think!

An easy one this time round. However, as before, this is a genuine coding error that I found in a live Siebel environment! As usual, a virtual prize (i.e. no prize) to the first poster to spot what’s wrong!

function CodeChallenge2(sContactId)
{
  // Declare variables
  var boContact, bcContact;

  try
  {
    // Instantiate new BC instance
    boContact = TheApplication().GetBusObject("Contact");
    bcContact = boContact.GetBusComp("Contact");

    with (bcContact)
    {
      // Create query context
      ClearToQuery();
      SetViewMode(AllView);
      SetSearchSpec("Id", sContactId);
      ExecuteQuery(ForwardOnly);

      // If record is found, update the status
      if (FirstRecord())
      {
        SetFieldValue("Status", "Active");
        WriteRecord();
      }
    }
  }
  catch(e)
  {
    // Call the custom LogError function to write error to error log
    LogError("Woops, an error has occurred!");
  }
  finally
  {
    // Destroy objects
    bcContact == null;
    boContact == null;
  }
}

Answers on a postcard or using the comments box below!

VN:F [1.9.14_1148]
Rating: 0.0/10 (0 votes cast)

Siebel SQL Log Analyser

I’ve been messing around with Visual C# 2010 Express. Say what you like about Microsoft, but their tools are awesome and freely available. I’d highly recommend you download and install it, if you fancy learning a new language such as C#.

As a little project to get me started, I designed and developed a simple tool to parse a Siebel log file, extracting SQL performance information and presenting it in a useful manner. The tool relies on the logs having been generated with appropriate SQL event log levels or using SIEBEL_LOG_EVENTS=4 in the Dedicated Web Client.

 

The tool uses two fantastic, freely available, open source controls that I found through the Code Project and Stack Overflow:

My thanks go out to the authors of these tools for their amazing work and for making their code available to all.

You can download the tool here and the source code here – you’ll need Visual Studio C# 2010 Express Edition or better to compile the source.

The code is distributed under the GNU General Public License.

Any comments or defect reports, please feel free to post below.

VN:F [1.9.14_1148]
Rating: 0.0/10 (0 votes cast)