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!



