Pages

Coding Date and Time in Siebel eScript

The following example shows how current date is obtained and parsed in business service (BS) scripts so that the date value can be used to update a BC field:

var sToday = new Date;
var sNow = "01/01/2012";
var sYear = sToday.getFullYear();
var sMonth = sToday.getMonth() + 1;
if (sMonth < 10) {sMonth = "0" + sMonth;}
var sDate = sToday.getDate();
if (sDate < 10) {sDate = "0" + sDate;}
var sHour = sToday.getHours();
if (sHour < 10) {sHour = "0" + sHour;}
var sMinute = sToday.getMinutes();
if (sMinute < 10) {sMinute = "0" + sMinute;}
var sSecond = sToday.getSeconds();
if (sSecond < 10) {sSecond = "0" + sSecond;}
sNow = sMonth + "/" + sDate + "/" + sYear + " " + sHour + ":" + sMinute + ":" + sSecond;
//TheApplication().RaiseErrorText(sNow);
SetFieldValue("Match Date", sNow);
Notes:
Functions such as TimeStamp(), Today() cannot be used in Business Service scripts.
Clib functions no longer work in our system (don’t know why).  They are not working:
//Clib.strftime(sToday, "%m/%d/%Y %H:%M:%S",Clib.localtime(sToday.toSystem()));
//Clib.strftime(sNow,"%m/%d/%Y %H:%M:%S",Clib.localtime(Clib.time()));

SetFieldValue("Match Date", sNow) can only pass in the mm/dd/yyyy part but not the time info, thus the hr:mi:ss of the updated date will be all 0.

Function TheApplication().RaiseErrorText(stext) can be used to display a message or show a value.  However codes after this function will not be executed.

The vailable sToday cannot be used to update BC field of Date type directly because of its format.  Error SBL-DAT-00359 will occur.

No comments:

Post a Comment