Siebel Code Challenge – #11

UPDATED: An easy one, I guess – well done to Ranjith and Rahul for spotting the mistake. Although Oracle uses a percentage sign (%) as a wildcard character, Siebel uses an asterisk (*). As such, the SQL that get generated for the query below will actually check for a literal ‘%’ as part of the string. Personally, I know of very few Mr and Mrs Smit%!

A real doozy today! We came across this when debugging an incident – see if you can spot the mistake in the following eScript:

function CodeChallenge11()
{
  // 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);
      SetSearchSpec("Last Name", "Smit%");
      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!");
    return(-1);
  }
  finally
  {
    // Destroy objects
    bcContact = null;
    boContact = null;
  }
}

As usual, please add your comments below. No prize this time – I have a family to feed you know. ;)

VN:F [1.9.22_1171]
Rating: 5.8/10 (4 votes cast)
Siebel Code Challenge - #11, 5.8 out of 10 based on 4 ratings

Comments

  1. Is it the line

    SetSearchSpec(“Last Name”, “Smit%”); ?
    Should it be SetSearchSpec(“Last Name”, “Smit*”) ; ?

    Since there is no GetFieldValue on field ‘Last Name’, it does not have to be Activated.

    VN:F [1.9.22_1171]
    Rating: 0 (from 0 votes)
  2. Rahul says:

    Hey Oli,
    I believe we should have * or ? instead of % in the searchspec if the idea is to search contacts with last name like Smit. Keep throwing pints even half filled will do. :)

    Regards,
    -Rahul-

    VA:F [1.9.22_1171]
    Rating: 0 (from 0 votes)

Leave a Reply