July 09, 2016

How to add delay in Siebel eScript/Workflow?

Disclaimer: Ideally you should never have to create delay in Siebel, you must be doing something absolutely wrong or something amazingly innovative if you have to add delay in Siebel script or Siebel workflows.
How to add some delay in Siebel Script?

Let's assume for some(god forbid) reason you need to create delay of some seconds in Siebel escript or workflow, then how will you do it? 

Siebel provides sleep step in workflows that can be used to create delay for interactive workflows, but there is no way (documented) to create delay for service workflows or in scripts. Let's see what workarounds do we have.

Solution 1: User operating system timeout in script. 

Siebel can invoke operating system commands by Clib.system function, these functions wait till time command is successfully completed by operating system. 
Clib.System("timeout 2"); // Two second delay in windows hosted environment

or 
Clib.system("sleep 2"); // Two second Linux hosted environment.

This instruction will call operating system timeout command to create delay and Siebel will wait for command to finish and only after the specified time Siebel will continue with rest of the code. 

Solution 2:  Use EAI File Transport service to read an non existent file and with FileSleepTime parameter to create delay.

This will cause Siebel to wait for file for at least time specified before timing out, an then proceed with workflow. Make sure you use exception branch in for this step to proceed.

Solution 3:  Use asynchronous server request business service to execute subprocess at specified time in future. 
This solution doesn't garuntee the execution on that time, but works perfectly fine incase there is some degree of tolerance.

July 07, 2016

How to customize siebel error messages?


With IP14 Oracle has provided ErrorObjectRenderer.js to replace browser based dialogs with jQuery based dialogs. Problem with browser based dialogs is that users can accidently disable them. Thus it is not a good place to show error messages or important instructions to the user. 
Standard alert()
However jQuery based dialogs always shows up on the screen and user have to click ok always to get past them.
jQuery Dialog

Lets see how we can achieve the same functionality in IP13.  

Open UI framework uses browser alert() function to popup error messages. In Javascript it is possible to override any function including browser native functions like alert and change it according to the business needs.

Simplest way to override alert is to define a function alert() in your code, this will force your browser to call your custom function all the time whenever Siebel calls alert() instead of browser's native function. .

function alert(str){
 $("<div id='my_error'>" + str + "</div>").dialog({
               modal: true,
                buttons: [{ id: "btn-accept",
                    text: "Ok",
                    click: function () { $(this).dialog("close"); }               
                }]
            });
}

Just add the above code in post load file and job done, after executing this code all the error messages will shown in jQuery dialog which will always pop-up. See it in action on codepen

Happy alerting ! 
This is trick is shared by avid reader TJ, please share your tips and tricks in comments below.

July 03, 2016

WebServices Performance Tuning



Recently I have been working on high traffic and highly available web service which is hosted by Siebel. I was asked to improve performance of it. I checked all the places for any performance degradation clues, there was hardly any, all queries were on indexed columns and thin BC's were used, there was no fat whatsoever.

With all the logs and spool generation my focus went to these two problems. 

1. Before every web service call Siebel was requesting file system to write read user preference file which was taking fair bit of time due to contention at file system. You might see following in logs, if user preference file is corrupted.



ObjMgrLog Debug 5 0 2016-06-29 06:50:56 SharedFileReader: \SiebelFS\userpref\EAIUSER&Siebel Sales Enterprise.spf: Open iteration 0 failed. errcode = 2.


This file read was absolutely unnecessary, luckily there was a way to turn off by setting "OM - Save Preferences" to FALSE for EAI object manager. This will make all logins to avoid looking up for user preference file.

2. Another useless transaction I noticed was with database. It was when Siebel tries to update the last login date on S_USER record. 
In logs you can see queries like these:

UPDATE SIEBEL.S_USER SET
LAST_LOGIN_TS = :7,
MODIFICATION_NUM = :8,
LAST_UPD_BY = :9,
LAST_UPD = :10,
DB_LAST_UPD = current_date,
DB_LAST_UPD_SRC = :11
WHERE
ROW_ID = :12 AND MODIFICATION_NUM = :14;
This can also be turned off in recent Siebel versions by setting DisableLastLoginTS = TRUE 

Its a new parameter introduced by Oracle, you can read more about this parameter on oracle support 1665762.1

Hope it helps. If you have come across any such parameter which can improve performance then please share it in comments below.