30 December 2010

Siebel: User Defined Objects

Ever missed all the OOP goodness in Siebel? Although not used frequently, user defined objects provide you with some degree of control with hiding complexities in scripting. No, this will not help you attain OO nirvana - but you can start doing things with the custom objects and prototyping (another post for another day) to:

  • Hide complexity
  • Provide scalability
  • Save memory while doing the above

Here’s a simple example that demonstrates use of user-defined objects. To test, you simply copy the code in a new client business service and you are all set.
First the Service_PreInvoke method:

function Service_PreInvokeMethod (MethodName, Inputs, Outputs)
{
var qryBC;

qryBC = new GetRecord("Contact", "Contact", "[Id] = '0-1'", "First Name", "Last Name");
Outputs.SetProperty("First Name", qryBC.Values[3]);

Outputs.SetProperty("Last Name", qryBC.Values[4]);

return (CancelOperation);

qryBC = null;
}

Next comes the constructor:

function GetRecord ()
{
try {
var arrValue = new Array();
var iCount;

if (arguments.length < 4) TheApplication().RaiseErrorText("I need minimum four arguments - BO name, BC
name, SearchExpr and at least one field name.");

var bo = TheApplication().GetBusObject(arguments[0]);
var bc = bo.GetBusComp(arguments[1]);
with (bc){
ClearToQuery();
SetViewMode(AllView);

SetSearchExpr(arguments[2]);
for (iCount = 3; iCount < arguments.length; iCount++){
ActivateField(arguments[iCount]);
}
ExecuteQuery(ForwardOnly);
}

if (bc.FirstRecord()) {
for (iCount = 3; iCount < arguments.length; iCount++){
arrValue[iCount] = bc.GetFieldValue(arguments[iCount]);
}
}
this.Values = arrValue;
} // try

catch(e){
throw(e);
}

finally{
arrValue = null;
bc = null;
bo = null;
}
}

Now, the explanation:
Purpose:

Provide ability to query any given BO / BC and retrieve the specified field values

How did we do that:

First, we create an object called “qryBC”, which becomes instance of a class “GetRecord” when the constructor “GetRecord()” is executed. Since this is the very first exposure to the class/object concept, we are letting the constructor do all the work rather than splitting it up. At this time we also pass the arguments to the object, whereby the constructor will query and return you the results. For simplicity in further processing, we return an array with the query results. Note the use of ‘this’ in the constructor and the reference to the set values when retrieving results in PreInvoke method.

Never understood why OO beats procedural programming you say? You need to depend your friend Google to find out what you missed.(cross posted elsewhere)

28 December 2010

CRM 2011!

It is that time of the year folks - time when you, I and every IT guy worth his salt tends to get clobbered with analyst talk. This is all about the past year - how they prophesized just right, and how the world is converting to paradise or is getting destroyed in the nuclear winter next year. Since I too am finding myself putting together hard-to-comprehend words one too many times, I thought this is something ought to be addressed pronto (before you sink too deep in the holiday mood that is). Since CRM is what I am doing all the time (it is actually Siebel application development, but it feels liberating to be more generic), this is a short list of what I think should happen to CRM in 2011.

  1. Fusion should come out of its wraps
    Inspite of Elison's jab at the implementable state of Oracle Fusion apps, I quite look forward to it. In the process, I also look forward to throwing out all the experience of developing lousy scripts using eScript/Siebel VB, half-baked COM interfacing programs, workflows with a clunky interface and all the configuration fun that can be had in any version of Siebel apps post v7. I will miss dismissing customer requests with a hard-hitting statement - "the functionality is tagged to SRF, and cannot be changed now". 2011 is a good year to brave up to J2EE, ODI, WebCenter, WebLogic and other hotchpotch. This is number one solely because I am associated with Siebel for too long a time.
  2. SaaS triumps in Large Enterprises
    Yes, I know this has been said since the inception of SFDC and the glorious just-dream-forces unleashed upon us. But it is not hard to listen when businesses (not IT) is shouting at you about why they should be spending so much on CapEx and ongoing maintenance including upgrades. So there will be a slew of studies on SaaS take-over, hybrid architectures and how many millions one saved while firing the software and the dream-teams which were keeping them afloat. Well, this cannot happen in next year alone but will enable me to brag about how it came true to a certain extent at the end of 2011.
  3. Mobile to the Rescue!
    Mobile phones with their ubiquity and affordability, should wield greater power over deciding the CRM strategy. How many of us wants to navigate the shiny website of Airtel when the transactions can be done through mcheck? CRM will get more focussed in the mobile space, true for developed and developing countries alike. App development, here I come!
  4. Social CRM will bring down companies to their knees
    Well, I sort of made it up - companies don't have knees. Service companies especially will struggle to keep an eye on what is going on, and would have to resort to several IT adventures before they can get things right. A piece of copied advice - it is not about IT guys (a.k.a 'dont blame me'), set your focus on what you want to do when customers are talking all good or bad about you.
  5. Paul Greenberg should be crowned the undisputed thought-leader of CRM
    I really like his way of writing - the book and the blog, even with my zero knowledge of baseball. Though I feel he vastly over-rates the power of getting Social, being a undisputed leader will push to the fore-front his genial thoughts on maintaining good customer relationship.

27 December 2010

Siebel: Importing data from files

I am back after a not-so-brief hiatus, and am back hopefully for good :). Here I am with yet another utility - this time something that will help you to import data from files into Siebel, with zero coding required from your end. ‘COG File Import Service’ as it is known, will hopefully simplify your life a bit.

Contrary to popular (and let me add, buggy) excel macros / VB COM programs that are available to load data to Siebel, this is a business service that can be imported to Tools / Client. But at the same time it does not offer as much flexibility, given below are a few things that make this tool stand apart.

Why another tool?
File import is nothing new to Siebel developers. But why use another tool when there are dime-a-dozen you say? Thus goes the story:

  • The first thing that hits you - most of the tools to load Siebel data have inconsistent interfaces, and may require some amount of ‘getting-used-to’
  • External objects or platforms are required to actually see what is going on, and hopefully to change the behavior. For example, you need Excel or Visual Basic software, or have a dependency on Windows platform to execute the code. And all that can be done, provided you understand what has been written there
  • Customers might have their own restrictions in connecting to production systems using third party software and utilities

The Mechanism


COG Import Service is just a business service that can be applied to Siebel v7.5+, but has only been tested with 7.7 and 8.1. The service works with CSV/delimited files and has two distinct ways to handle them:

  1. Simple Update - This is just a wrapper to the OOB CSV reader service, with a couple of enhancements thrown in
  2. Update - A more sophisticated updater, which can do a few more things than what CSV reader can do

The steps involved in both methods are simple:

  1. Read file (all at once)
  2. Map fields to provided content
  3. Use a data map, if specified
  4. Update

Where they differ is in the way they process files.



When to use which method?


.. Simple Update

  • Uses the 'CSV Reader Business Service', and hence needs an integration object (IO) to be available for the input data
  • When the processing is simple and there is no need for processing more than one component/entity (in other words, entity and its children) at one time
  • Processing should be fast
  • Any errors should roll-back all transactions

.. Update

  • Can be used with or without involving IO
  • Delimited with be comma or something else
  • Process entity and one child with one operation


How to Use?


Import the attached XML into Siebel Tools and compile to SRF, or imported into the Client (Site Map > Business Service Administration). Parameters to the service specify the parameters that are needed for a successful run. The file formats/structure has been documented in the service itself.



License


None, you can use it or throw it away. Use it at your own risk, unintentional bugs are all but risks of the trade.

You can watch this space (at your own risk, of course) for new versions - improvements or bug fixes.

26 September 2010

Fusion - at last

Well, the moment we have been waiting for is here - Oracle Fusion CRM finally finds the light of the day (so as to speak) in the recent Oracle Open World. This is a new technology framework folks, put on your best armour and start preparing for all new things coming your way. You can start with http://www.oracle.com/fusion! No, no downloads yet - you should satisfy yourself with the latest sales pitch. Alternately, you can take your frustration to the Siebel 8.3 Statement of Direction (available on support.oracle.com).

21 March 2010

Siebel: Querying for Distinct Records

Many a time during Siebel configuration, one is left wondering "so near yet so far" - to SQL that is. A recent scenario had this problem - send alerts to the activity's account's team members when it is past the due date. Sending more than one email for one or more pending activity is
not acceptable. One of the common things that we do when confronted with this problem is to just write a workflow or a piece of code somewhere that can:
  1. Query for all activities past the due date

  2. For each activity, get the account and query for the
    account's position team

  3. For each member of the team, get the corresponding primary
    employee

  4. Send notification/alerts and flag him to be ignored in
    future

Looking at this problem from a different angle, the solution
is somewhat more simple - get unique "account team member" - "activity"
combination that will be the potential notification candidate. Siebel
provides a "Distinct" property on business components that helps us to
achieve just this. Note that this property enforces a "DISTINCT" clause
on all fields present in the BC, which may force us to create a clone
when needed. Let us re-look at the solution now:
  1. Create a BC based on S_EVT_ACT and with the following
    fields:
    • Due Date (DUE)
    • Status (EVT_STAT_CD)
    • Account Id (OU_ID)
    • Account Primary Position Id (S_ACCNT_POSTN.POSITION_ID)
      • Join: S_EVT_ACT.OU_ID = S_ACCNT_POSTN.OU_EXT_ID)
    • Account Primary Employee Email (S_CONTACT.EMAIL_ADDR)
      • Join: S_ACCNT_POSTN.POSITION_ID = S_POSTN.PAR_ROW_ID
      • Join: S_POSTN.PR_EMP_ID = S_CONTACT.PAR_ROW_ID

  2. Enable "Distinct" flag on this BC

  3. Create a simple workflow based on a business object which
    has the above BC as primary and which leverages the ""Outbound
    Communications Manager" service

  4. Create a "Repeating Component Request" with the required
    search criteria - "[Due] = Today() AND [Status] = 'Open'"

Well, how is that? Of course both have the same number of steps and the second one actually looks more pronounced. But if you have done a fair bit of coding and solutions to problems such as these you know what to choose.

06 March 2010

Siebel: Batch Script to Compile and Replace SRF

Well, I have been absent - you can't really blame me since I had nothing to say. But I am back and hope that matters at least a bit.

My recent work involved some digging around to compile SRF frequently and was surprised that there was hardly any ready-made way to do that. This is the state even though Siebel has been providing 'command line' syntax to do a number of things using Tools. So the following batch script was born for Microsoft Windows OS. It is not really that difficult to achieve it for other operating systems if you apply your mind a bit. I can no way call this script as my own, it is just putting together of many pieces. A brief explanation follows for the uninitiated.

The complete script can be found at the end of this post. To make it run just open notepad > copy the entire script and save the file as "CompUp.bat". If you just double click the file, there is no log created. It will be mighty helpful for the script to create appropriate logs - this will do it:
"d:\sba81\Compile\CompUp.bat 1>>d:\sb\Compile\CompUp.log 2>>&1"

Let us look at individual sections of the script:

Initiation
Set a few variables which can change across environments.
@set SBL_ROOT=d:\sba81
@set SBL_TOOLS_ROOT=d:\sba81\tools
@set SRF_BACKUP=d:\sba81\Compile\SRFArchive
@set SRF_FOLDER=%SBL_ROOT%\siebsrvr\objects\enu
@set BSCRIPT_FOLDER=%SBL_ROOT%\siebsrvr\webmaster\enu

@set OLD_SRF=siebel_sia.srf
@set NEW_SRF=siebel_sia-%TODAY:~10,4%%TODAY:~4,2%%TODAY:~7,2%%NOW:~0,2%.srf
@set CFG=%SBL_ROOT%\siebsrvr\bin\enu\epharma.cfg

@set SIEBEL_SERVER="my_Siebsrvr"
@set WEB_SERVER="my_Webserver"
Most of it is standard stuff, you might observe that the NEW_SRF is named such that repeated compiles on a single day will not cause any harm - assuming each compile takes at least an hour to complete. Pick any CFG of your choice. Siebel server, web server and gateway parameters are copied from the service names. To view service names go to Windows Start Menu > Run > Type 'services.msc' > Hit OK. In services windows go to 'Properties' of the appropriate service and locate the name - these do not have spaces.

Compile
Next comes the actual compile - use Siebel Tools command line options to initiate compile. When the batch file is being executed, you may actually see Tools open up, compile SRF and close.
@ECHO %DATE% %TIME%: Compile SRF with %SBL_TOOLS_ROOT%\bin\enu\tools.cfg
@%SBL_TOOLS_ROOT%\bin\siebdev.exe /c %SBL_TOOLS_ROOT%\bin\enu\tools.cfg /d ServerDataSrc /u /p /bc "Siebel Repository" %SRF_BACKUP%\%NEW_SRF%
@IF %ERRORLEVEL% NEQ 0 GOTO ERR_HANDLER

One obvious point here is that you need Tools to be installed on the server. If you are using a box that cannot have Tools (or using other operating systems), you may need to write additional statements to telnet (or something similar) to the Tools box, compile SRF and transfer the same to Siebel server machine. If everything runs fine you will have the SRF compiled, hurray! On the other hand, if there is an error the batch execution just stops without executing further statements. These are scattered throughout the script to direct batch execution in case of errors.

Replace SRF
Now, stop the server to enable us to replace SRF.
net stop %SIEBEL_SERVER%
@sleep 120
The sleep is required to wait for the server to actually stop. During execution you may note that 'net stop' command tells us that the service could not be stopped. What really happens is that it waits for too small a time for server to come down. 'sleep' can hold the further execution till defined time (120 seconds) to enable the siebel server to completely shutdown. Next step: replace srf.
move /y %SRF_FOLDER%\%OLD_SRF% %SRF_BACKUP%\%NEW_SRF%_old
move /y %SRF_BACKUP%\%NEW_SRF% %SRF_FOLDER%\%OLD_SRF%
Copy the newly compiled SRF to Siebel server, while rename the old SRF to denote the SRF it was replaced with. Next generate browser script:
%SBL_ROOT%\siebsrvr\bin\genbscript %CFG% %BSCRIPT_FOLDER%
and start Siebel server:
net start %SIEBEL_SERVER%
Just in case you were wondering, we don't need to wait for the Siebel server to actually startup. Restart Web Server service to put the new browser script in action.
@REM net stop %WEB_SERVER%
@REM net start %WEB_SERVER%
As an alternative you can always follow the SWE command route to refresh browser scripts. Well, that was easy wasn't it?

Complete Script
You can download the batch file here.
@REM Compile and Upload Utility - Batch file to compile SRF and 'activate' it on Siebel server
@REM This is the Windows version! Use command "d:\sba81\Compile\CompUp.bat 1>>d:\sb\Compile\CompUp.log 2>>&1" to redirect o/p & error to log
@REM

@set COMPUP_LOG=d:\sba81\Compile\CompUp.log

@ECHO ====================================================================================================================
@ECHO %DATE% %TIME%: CompUp starting up..
@ECHO %DATE% %TIME%: Set variables

@set TODAY=%Date: =0%
@set NOW=%Time: =0%
@set SBL_ROOT=d:\sba81
@set SBL_TOOLS_ROOT=d:\sba81\tools
@set SRF_BACKUP=d:\sba81\Compile\SRFArchive
@set SRF_FOLDER=%SBL_ROOT%\siebsrvr\objects\enu
@set BSCRIPT_FOLDER=%SBL_ROOT%\siebsrvr\webmaster\enu

@set OLD_SRF=siebel_sia.srf
@set NEW_SRF=siebel_sia-%TODAY:~10,4%%TODAY:~4,2%%TODAY:~7,2%%NOW:~0,2%.srf
@set CFG=%SBL_ROOT%\siebsrvr\bin\enu\epharma.cfg

@set SIEBEL_SERVER="my_Siebsrvr"
@set WEB_SERVER="my_Webserver"

@ECHO %DATE% %TIME%: Compile SRF with %SBL_TOOLS_ROOT%\bin\enu\tools.cfg
@%SBL_TOOLS_ROOT%\bin\siebdev.exe /c %SBL_TOOLS_ROOT%\bin\enu\tools.cfg /d ServerDataSrc /u /p /bc "Siebel Repository" %SRF_BACKUP%\%NEW_SRF%
@IF %ERRORLEVEL% NEQ 0 GOTO ERR_HANDLER

@ECHO %DATE% %TIME%: Stop Siebel server %SIEBEL_SERVER%..
net stop %SIEBEL_SERVER%
@sleep 120
@IF %ERRORLEVEL% NEQ 0 GOTO ERR_HANDLER

@ECHO %DATE% %TIME%: Copy SRF
move /y %SRF_FOLDER%\%OLD_SRF% %SRF_BACKUP%\%NEW_SRF%_old
@IF %ERRORLEVEL% NEQ 0 GOTO ERR_HANDLER
move /y %SRF_BACKUP%\%NEW_SRF% %SRF_FOLDER%\%OLD_SRF%
@IF %ERRORLEVEL% NEQ 0 GOTO ERR_HANDLER

@ECHO %DATE% %TIME%: Generate browser script
%SBL_ROOT%\siebsrvr\bin\genbscript %CFG% %BSCRIPT_FOLDER%

@ECHO %DATE% %TIME%: Start Siebel server %SIEBEL_SERVER%
net start %SIEBEL_SERVER%
@IF %ERRORLEVEL% NEQ 0 GOTO ERR_HANDLER

@REM ECHO %DATE% %TIME%: Restart Webserver %WEB_SERVER%
@REM net stop %WEB_SERVER%
@IF %ERRORLEVEL% NEQ 0 GOTO ERR_HANDLER
@REM net start %WEB_SERVER%
@IF %ERRORLEVEL% NEQ 0 GOTO ERR_HANDLER

@GOTO End

:ERR_HANDLER
@ECHO Job failed! Error Code: %ERRORLEVEL%. Refer log file for further details.

:End
@ECHO %DATE% %TIME%: CompUp end!