Siebel Code Challenge – #10

UPDATED: Well done Rick for spotting this one! It is considered bad practice to return from a finally block – the behavior of the code is unpredictable, based on the route the code takes and whether an exception is thrown or not. Here’s some further reading on the subject. If an exception must be thrown, the return should happen outside of the try…catch. If the function must return a value, the catch should return a value, for example -1, while suppressing (not throwing) the exception.

Really quick one today! I found this in loads of code at my latest project – can you identify the problem?

function CodeChallenge10()
{
  // Declare variables
  var boContact, bcContact;
  var numContact = 0;

  try
  {
    // Instantiate new BC instance
    boContact = TheApplication().GetBusObject("Contact");
    bcContact = boContact.GetBusComp("Contact");
    with (bcContact)
    {
      // Create query context
      ClearToQuery();
      SetViewMode(AllView);
      ExecuteQuery(ForwardOnly);

      numContact = CountRecords();

      return numContact;
    }
  }
  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;
    return numContact;
  }
}

Answers below, please!

VN:F [1.9.17_1161]
Rating: 0.0/10 (0 votes cast)

Repository Analyser – Development Update

When I find a spare moment, I’ve been working away on my C# Repository Analyser tool. I’ve re-jigged the UI a little and added a new piece of functionality that can be used as part of your configuration management processes – Change Log. This process will parse the Siebel Repository, via Siebel Business Objects, and pull out all changes made after the date specified on the form. This gives you an immediate view of who has changed what objects, in order to validate the objects that you’re about to deploy against those you have planned to change as part of your solution design process:

Connect

Picture 1 of 3

There are also a number of small changes:

  • New app layout with a ‘Connect’ page to specify Siebel server login details
  • New ‘Change Log’ functionality to show all objects changed since a given date, by type
  • New option to export change results to XML
  • New reference counts for the script count functionality, showing standard script volumes in 7.8, 8.1 and 8.2 vanilla installations

And coming up soon:

  • Script Search function to search across all script in the repository, without the pain of the ‘Find in Repository’ functionality in Tools
  • Script Problem Finder function to identify memory leaks, return in finally and other common eScript errors
  • Config Problem Finder function to identify common configuration errors, such as missing ‘Link Spec’ properties and use of ‘Force Active’ field in Join specifications
  • And more!

Keep you eyes peeled for an official release very soon!

 

VN:F [1.9.17_1161]
Rating: 9.0/10 (1 vote cast)

Comparing properties in Siebel Workflow

I came across this in a live Workflow the other day:

What’s happening here is that the comparison of two Workflow Process properties is being done in a custom, eScript Business Service. Further digging revealed that the ‘Is Num >= Max?’ step invoked the following eScript:

function GreaterThanOrEqual(Inputs, Outputs)
{
  var res = "Y";
  var val1 = new Number(Inputs.GetProperty("Value1"));
  var val2 = new Number(Inputs.GetProperty("Value2"));

  if (val1 >= val2)
  {
    res = "Y";
  }
  else
  {
    res = "N";
  }

  Outputs = res;
  return (Outputs);
}

Apart from the obvious problems with this code, it struck me as a very round about way to compare two properties within a Workflow.

So I replaced it all with a single, expression based decision step:

Does anyone have any examples of their own of ‘over engineered’ solutions to simple problems?

VN:F [1.9.17_1161]
Rating: 0.0/10 (0 votes cast)

Repository Analyser – Source Code

My Repository Analyser tool uses some cool code to connect directly to the Siebel Server object manager instance, via C#. It also does some neat things using the Repository BC’s which underly Siebel Tools.

In the spirit of sharing, I want to make the source code available to you all under the GPL – you can download the source code here,

As with all the source that I’ve released, I’d really love to hear from anyone who has made some awesome app or solved some crazy problem  with the code – it’s there for you to use but I’d really appreciate hearing where it’s being applied.

I’ve been doing some really interesting things with this idea, building a set of useful tools and functions – I’ll keep you posted as and when I develop and release new functionality.

VN:F [1.9.17_1161]
Rating: 10.0/10 (1 vote cast)

Siebel Code Challenge – #9

UPDATED: Thanks to Rick for spotting this one! The Today() function returns today’s date without a time component. As there is specialised class validation functionality all over the Action BC, the Workflow will fail if the planned start date is any time today – regardless if it’s before the current time or not. Using the Timestamp() function, within the operation step, will achieve the result expected by the developer.

By special request from Rahul, I give you Siebel Code Challenge #9 – Return of the Code Challenge!

This is something I came across recently – you need to think about the context of vanilla validation in the Action BC to realise why this Workflow isn’t quite right.

This is such a simple mistake but one that can really affect the logic that the developer has in mind. Comments and answers below, please!

VN:F [1.9.17_1161]
Rating: 0.0/10 (0 votes cast)