December 08, 2016

How to find the siebel log files using command line?

While working on Siebel projects you must have come across numerous occasions where you need to find specific log with specific error or any one user name or any one xml value which is causing trouble.



Usually this type of task involve tedious task of opening all the log files during the time duration one by one. 

November 11, 2016

Date Manipulation in Siebel eScript

We have seen how to manipulate date values in Siebel Workflows. In this post we will see how can we work with date variables in Siebel eScript and use them to work with date fields.

I am not the author of these functions, It is just collection of useful functions that I have implemented in few projects. Please feel free to share your coding tricks for date variables in comments below.

Date Functions in Siebel eScript
Date Functions in Siebel eScript

How to add days to a date?


function AddToDate(sourceDate, nDays, nHours, nMinutes, nSeconds, nsign)
{
   // sourceDate  :  Date object
  // nDays, nHours , nMinutes , nSeconds  :  Integer numbers
  // nsign : Can have two values : 1 or ­1
  //             1 indicates to ADD to the sourceDate
  //            ­1 indicates to SUBTRACT from the sourceDate
  // Returns : A date object, after adding/subtracting
  // ndays,hNours,nMinutes
  //          and nseconds to the sourceDate.
  var retDate = sourceDate;
  retDate.setDate(retDate.getDate()+nsign*nDays);
  retDate.setHours(retDate.getHours()+nsign*nHours);
  retDate.setMinutes(retDate.getMinutes()+nsign*nMinutes);
  retDate.setSeconds(retDate.getSeconds()+nsign*nSeconds);
  return (retDate);
}

 How to find difference of days between two dates?

function DiffDays(date1, date2)
{// date1 : Date object
// date2 : Date object
// Returns : Number of days between date1 and date2
return ((date2.getTime()­ - date1.getTime())/(1000*60*60*24));
}

How to convert date object to String?

function DateToString(dDate)
{
  // dDate  :  Date object
  // Returns : A string with the format "mm/dd/yyyy" or "mm/dd/yyyy
hh:mm:ss"
  var sMonth = ToString(dDate.getMonth() + 1);
  if (sMonth.length == 1) {sMonth = "0" + sMonth;}
  var sDay = ToString(dDate.getDate());
  if (sDay.length == 1) {sDay = "0" + sDay;}
  var sHours = ToString(dDate.getHours());
  if (sHours.length == 1) {sHours = "0" + sHours;}
  var sMinutes = ToString(dDate.getMinutes());
  if (sMinutes.length == 1) {sMinutes = "0" + sMinutes;}
  var sSeconds = ToString(dDate.getSeconds());
  if (sSeconds.length == 1) {sSeconds = "0" + sSeconds;}
  if (sHours == "00" && sMinutes == "00" && sSeconds == "00")
    return (sMonth +"/"+  sDay +"/" + dDate.getFullYear())
  else
    return (sMonth +"/"+  sDay +"/" + dDate.getFullYear() +"
"+sHours+":"+sMinutes+":"+sSeconds);

}

  How to convert String to Date Object?


function StringToDate(sDate)
{
  // sDate  :  A string with the format "mm/dd/yyyy" or "mm/dd/yyyy
hh:mm:ss"
  // Returns : a Date object
  var ArDateTime = sDate.split (" ");
  var  ArDate = ArDateTime[0];
  var  splitDate = ArDate.split ("/");
  var nDay = ToNumber(splitDate[1]);
ar nMonth = ToNumber(splitDate[0]);
  var nYear = ToNumber(splitDate[2]);
  if (ArDateTime.length == 1)
     return (new Date(nYear, nMonth­1 , nDay))
  else
  {  var ArTime = ArDateTime[1];
      var splitTime = ArTime.split(":");
      if (splitTime[0]=="00" && splitTime[1]=="00" && splitTime[2]=="00"
)
            return (new Date(nYear, nMonth­1 , nDay))
      else
      {
            var nHours     = ToNumber(splitTime[0]);
            var nMinutes   = ToNumber(splitTime[1]);
            var nSeconds = ToNumber(splitTime[2]);
            return (new Date(nYear,nMonth­1,nDay, nHours, nMinutes,
nSeconds))
      }
   }
}

How to find records created in past 5 days? 

var dToday = new Date();
var FiveDaysAgo =  AddToDate(today,5,0,0,0,­1);
var bo = TheApplication().GetBusObject("Service Request");
var bc = bo.GetBusComp("Service Request");
bc.ActivateField("Description");
bc.ClearToQuery();
bc.SetViewMode(AllView);
bc.SetSearchSpec ("Created", ">= " + "'" + DateToString(FiveDaysAgo)
+ "'");
bc.ExecuteQuery();
TheApplication().RaiseErrorText(bc.CountRecords());

How to compare two dates?

function CompareDates(dte_from,dte_to)
{
/* Function to compare two dates.. will return 1 if dte_from is greater than dte_to else will return 0 */
var myM = ToInteger(dte_from.getMonth()+1);
var myD = ToInteger(dte_from.getDate());
var myY = ToInteger(dte_from.getFullYear());
var toM = ToInteger(dte_to.getMonth()+1);
var toD = ToInteger(dte_to.getDate());
var toY = ToInteger(dte_to.getFullYear());
if ((myY < toY)||((myY==toY)&&(myM < toM))||((myY==toY)&&(myM==toM)&&(myD < = toD)))
 {
  return(0);
 }
else
{
  return(1);
}
}

How to find if date is a future date?


function IsFutureDate(mydate)
{
/*
 *  Function to check if a date is greater than today
 *  Returns 0 if Current Date is larger
 *  1 if Passed Variable is larger
*/

var istoday = new Date();   
var myM = ToInteger(mydate.getMonth()+1);
var myD = ToInteger(mydate.getDate());
var myY = ToInteger(mydate.getFullYear());
var toM = ToInteger(istoday.getMonth()+1);
var toD = ToInteger(istoday.getDate());
var toY = ToInteger(istoday.getFullYear());
if ((myY < toY)||((myY==toY)&&(myM < toM))||((myY==toY)&&(myM==toM)&&(myD < = toD)))
 {
  return(0);
 }
else
{
  return(1);
}
}

** Code is provided for conceptual purpose only, please test the code explained throughly before implementing in production environment.

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.

June 23, 2016

Just one Elastic applet?

Oracle introduced wonderful elastic list applets with IP16,  this feature shrinks list applet size if there are no or less records needs to be displayed. However this doesn't always looks nice, specially in MVG applets and pick applets.
Default Elastic Applets in IP16
 
This feature can be turned off by setting "Enable Elastic Grid" system preference, but it is turned off for entire application. That makes me think is there any way we can make only one applet as elastic applet?  Answer is yes :)

Neel on Siebel Unleashed published beautiful trick to back port elastic applets into IP15. Absolutely splendid! This trick can be extended to make only few applets Elastic. 

To make all list applets Elastic add following in custom CSS file:
.ui-jqgrid-bdiv{max-height:340px !important; height:auto !important;}
To make only one applet Elastic (After turning of the system preference) add following CSS :
div[title="Line Items List Applet"] div.ui-jqgrid-bdiv { height: auto !important}

By preceding another div selector to the CSS rule we can instruct browser to apply CSS style only if applet name is : "Line Items List Applet". One can use this trick to change other UI attributes for specific applets and apply different styling.


Happy Styling :)

June 21, 2016

Siebel Tools and Windows 10

Those who have been following blog closely would know from my latest demo video that I have been using windows 10 and Siebel IP16 for experimentation.

One can easily install Siebel Tools and client on windows 10 and run it on Oracle XE with Sample database, however Siebel IP16 being a new release it has some quirks which are not very developer friendly.

Here are some problems that I get everytime:

1. All workflows by default are not valid :(
Workflow simulator will error out straight away even if there is nothing wrong with workflow. Validator might say workflow is not fully connected.
Workflow simulation on Windows 10

What's the fix? Just edit the workflow once and move around workflow steps. And then simulate again, this time it will work just fine.

2. Tools wont boot and authentication subsystem will reject your login.
An internal error has occurred within the authentication subsystem for the Siebel application. Please contact your system administrator for assistance.(SBL-DAT-00565)
SBL-DAT-00565

Oracle XE is either crashed or booting up just give it few minutes have a coffee or something.


3. Dedicated client wont start
A system error occurred trying to start the command 'siebel.exe /c "C:\Siebel\16.0.0.0.0\Client\BIN\enu\scomm.cfg" /b "C:\Program Files (x86)\Mozilla Firefox\firefox.exe" /u SADMIN /p SADMIN /d SAMPLE_XE /h'.(SBL-DEV-00127)
Cant start dedicated client.

Just run tools as administrator and you will be fine.

Hope it helps.

My current setup includes: Windows 10, Siebel IP16, Oracle XE, Oracle Virtual Box containing : Windows 2008 Server which is hosting  > MSSQL Server + IIS + Siebel Server IP16.

June 17, 2016

Scriptless Challenge : How to constrain association list applet dynamically?

Association applet let's you associate records from an existing list of records. Unlike pick applets these association list applets doesn't have any out of the box way of constraining records.

Consider scenario: When opportunity type is internal, system should only show internal marketed products for opportunity in product association list applet and for opportunity type external system should show only external marketed products. Products are marked as internal and external by product type field.

Challenge: According to oracle there is no other way then scripting on web load of association applet to filter the records. Script can look something like following. And it works flawlessly.

Can you suggest any script less alternative?

function WebApplet_Load ()
{
var BO;
var ParentBC;
var BC;
var AccountId;
BO = TheApplication().ActiveBusObject();
ParentBC = BO.GetBusComp("Opportunity");
if(ParentBC.Name = "Opportunity")
{
    AccountId = ParentBC.GetFieldValue ("Account Id");
    BC = this.BusComp();
    with (BC)
    {
        ClearToQuery();
        ActivateField("Account Id");
        SetSearchSpec ("Account Id", AccountId);
        ExecuteQuery();
    }
}
ParentBC = null;
BC = null;
BO = null;
}


June 16, 2016

How to hide disabled buttons in Siebel Open UI?

With IP 15 and 16 Open UI themes have inclined towards bigger controls and more blank space on page, which is not bad thing but too much of it is making UI cluttered specially on small screens.

To fix this issue one can hide all disabled controls and all the white space around it. this can be done by simply adding following CSS and Open UI framework takes care of the rest.

button.appletButtonDis {
    display: none;
}

Further on to hide disabled menu items add :

li[aria-disabled=true]{
    display: none;
}

Siebel adds these classes and attributes to all the buttons on all applets and menus including new/query/delete icons to show them as disabled. Thus this change effects the entire application.

This post is contributed by esteem reader from down under via siebel-developers slack community. Register today to read more discussion like this.

June 06, 2016

Siebel Admin [Cheat Sheet]

I see many Siebel consultants(including me) searching web everytime to get correct syntax for Siebel server manager commands.

Although the syntax is so simple we still somehow manage to forget it :) I have created this cheat sheet from list of commands which I use day in day out. List contains command to increase log levels, shutdown startup components, creating components, starting server manager.

Feel free to download and print one for your desk.Download Here

Hopefully no more searching for commands to increase log level of siebel components :) cheers!