Skip to main content

Posts

Showing posts with the label eScript

How to remove Line Breaks from a string using Siebel eScript

In Siebel if you copy the value from field (which have line break character) and paste in notepad it will look fine, but when you use query step in workflow or script and check the logs, the search spec will have a large white space due the line break character stored in data base of that specific column and query will not work. For removing line breaks in a field you can use below eSciprt. Line breaks in strings Windows: \r\n carriage return followed by newline character. Linux: \n just a newline character. Regular Expression: if(MethodName == "Remove LB CR")     {         var vTemp = Inputs.GetProperty("vIn");         vTemp = vTemp.replace( /[\r\n]+/gm, "");         Outputs.SetProperty("vOut",vTemp);         return (CancelOperation);     }   See Also: How to remove Line Break when selecting data from SQL Server

Find record query loop in Siebel eScript

  var EngBO, EngBC, EngId, RecordCount, withRecord, UserName, UserId; EngBO = TheApplication().GetBusObject("My Business Object"); EngBC = EngBO.GetBusComp("My Business Component");          with (EngBC)     {         ActivateField("Parent Id");         SetViewMode(AllView);         ClearToQuery();         SetSearchSpec ("Parent Id", ServiceId);         ExecuteQuery(ForwardOnly);         RecordCount = CountRecords();         withRecord = FirstRecord();                  while(withRecord)         {             EngId = GetFieldValue("Id");             UserNa...

Insert record through Siebel eScript

Insert Record through Siebel eScript var TBO, TBC; TBO = TheApplication().GetBusObject("My Business Object"); TBC = TBO.GetBusComp("My Business Componenet");     with(TBC)     {         NewRecord(NewAfter);         SetFieldValue("End Time",TE);         SetFieldValue("Start Time",TS);         SetFieldValue("Status","Active");         SetFieldValue("User Id",UserId);         SetFieldValue("Parent Id",EngId);         SetFieldValue("Date","08/10/2021");                     WriteRecord();     }

How to get desired characters from a String in Siebel eScirpt

substring() Method Extract desired characters from a String (Length Fixed) var SHRs, SMins, TimeStart = "10:30"; SHRs = TimeStart.substring(0,2); //0: Start, 2: End not included SMins = TimeStart.substring(3,5); Results: SHRs: 10 SMins: 30 -- -- -- -- -- -- -- -- -- --  -- -- -- -- -- -- -- -- -- --  -- -- -- -- -- -- -- -- -- -- Syntax stringVar.substring(start[, end]) start: An integer specifying the location of the beginning of the substring to be returned end: An integer one greater than the location of the last character of the substring to be returned Returns A new string, of length end - start, containing the characters that appeared in the positions from start to end - 1 of stringVar. Usage This method returns a portion of stringVar, comprising the characters in stringVar at the positions start through end - 1. The character at the end position is not included in the returned string. If the end parameter is not used, stringVar.substring() returns the characters fr...

How to get Day name from date in Siebel eScript

Below function in Siebel eScipt will return the Day from the date. Input: CurrentDate: 08/10/2021 (MM/DD/YYYY) Result: Tuesday var dayName, CurrentDate; dayName = GetWeekDay(CurrentDate);  -- -- GetWeekDay -- -- function GetWeekDay(currentDate) {     var weekDay, sDate, theYear, sDay = "", i = 0;     weekDay = new Array("Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday");     sDate = new Date(currentDate);     theYear = sDate.getFullYear()          while (i < sDate.getDay())     {         i++;         sDay = weekDay[i];     }     return(sDay); }

How to get today date in MM DD YYYY format in Siebel eScript

Below is eScript which will get the today's date: var CurrentDate, DateStart, MM, DD, YYYY; if (DateStart == "")         {             CurrentDate = new Date;             //above line will get the date in "Tue Aug 10 2021 13:30:45" format.             DD = CurrentDate.getDate();             MM = (CurrentDate.getMonth() + 1);             YYYY = CurrentDate.getFullYear();             DateStart = ToNumber(MM) + "/" + ToNumber(DD) + "/" + ToNumber(YYYY);         }

How to get today date for next year in MM DD YYYY format in Siebel eScript

Below sScript will help to get today's date with next year. Today: 08/10/2021 Result: 08/10/2022 var  CurrentDate, DateEnd, DD, MM, YYYY;  if (DateEnd == "")         {             //Next Year Date                CurrentDate = new Date;                //Tue Aug 10 2021 13:30:45             DD  = CurrentDate.getDate();             MM = (CurrentDate.getMonth() + 1);             YYYY = (CurrentDate.getFullYear() + 1);             DateEnd = ToNumber(MM) + "/" + ToNumber(DD) + "/" + ToNumber(YYYY);             //Outputs.SetProperty("OutTest",DateEnd);         }...

How to get Date difference in Days Siebel eScript

  Date input: MM/DD/YYYY format. Function will return date difference in Days. Inputs: DateStart: 08/10/2021 DateEnd: 08/11/2021 Result: DaysCount : 2   var DaysCount, DateStart, DateEnd; DaysCount = getDateDiff(DateStart, DateEnd);  -- -- -- getDateDiff -- -- -- function getDateDiff(DateStart, DateEnd) {     DateEnd  = new Date(DateEnd);     DateStart  = new Date(DateStart);     var diffDays = (DateEnd - DateStart)/(1000*60*60*24);     diffDays = ToNumber(diffDays)+1;     return(diffDays) }

How to sort and add search specification in Siebel Applet Load script

Normally we use Search specification filed in Applet List, but sometime we have to add long search expression which Search specification field can not contain (max length is 255 characters). For that we can add search specification in applet load server scripts. Right click on applet and from menu click on "Edit Server Scripts". From functions list click on "WebApplet_Load". First get the bussiness component by follow below script var oBusComp = this .BusComp () ; Now add with (The ' with ' statement adds the given object to the head of this scope chain during the evaluation of its statement body.) and statement Add Sort specification as below SetSortSpec( "Created(DESCENDING)" ); Now write search specification on the desired fields for mvl field you need to use "EXISTS". var Search1 = "EXISTS ([Case Contacts] = '" + case_id + "')" Using AND/OR you can extend the search specification. var Search1 = "...

How to query or find record in Siebel Business Component

You can perform query operation on Business Component through Workflow, eScript with the help of Siebel Operation, Inbound E-mail Database Operations (method: FindRecord) or EAI Siebel Adapter (method: Query but you need to create Integration Objects). This Business Component can be Virtual Business Component (VBC), External Business Component (EBC) or generic Business Component (BC).  See also: Difference Between Business Components and How to Create BC in Siebel through Object Wizard through Workflow with the help of Siebel Operation Create a workflow and provide the Business Object, business component should be in this BO for which you want to perform the query operation. From the Palettes window drag drop the Siebel Operation into workflow designer plane. Select the Siebel Operation box and open the properties window, provide the Business Component name from the drop down list and set Query in Operation field. You can set the search specification by two means either provide the...

How to convert date DDMMYYYY to MMDDYYYY through Siebel eScript

Below code will convert DD/MM/YYYY to MM/DD/YYYY date format. if(MethodName == "SETDATE")                 {                                 var LICENSEDATE = Inputs.GetProperty("DATEin");                                 var length = LICENSEDATE.length;  // Length Count                                                          ...

How to Split String through Siebel eScript

I have created a Business Service, which takes single input and split the name based on space return the final values in output arguments. Below is the script: var FullName = Inputs.GetProperty("Full Name"); var NameArray = FullName.split(" "); var FirstName = NameArray[0]; var SecondName = NameArray[1]; var ThirdName = NameArray[2]; Outputs.SetProperty("First Name", FirstName); Outputs.SetProperty("Second Name", SecondName); Outputs.SetProperty("Third Name", ThirdName); How to create Business Service in Siebel

How to create Business Service in Siebel

Create new record in Business Service, provide appropriate name and project. Create new record in Business Service Method, provide appropriate method name. Expand Business Service Method and create new records in Business Service Method Arguments and select Type as Input and Output. Right Click on Business Service name and click on Edit Server Scripts. In Service_PreInvokeMethod write your script. function Service_PreInvokeMethod (MethodName, Inputs, Outputs) { if(MethodName == "SET") { var IP = Inputs.GetProperty("in"); //Input Property name defined in Business Service Method Arguments var rep = /(-)/g; IP = IP.replace(rep , ""); Outputs.SetProperty("out", IP); //Output Property name defined in Business Service Method Arguments return (CancelOperation); } return (ContinueOperation); } Save, Compile and Test.

How to remove special character from a string through Siebel eScript

I have created a simple Business Service, which takes single input and check if that string contain "-" and it will remove and return the final value in output argument. Below is the script: var IP = Inputs.GetProperty("in"); var rep = /(-)/g; IP = IP.replace(rep , ""); Outputs.SetProperty("out", IP); How to create Business Service in Siebel

How add restriction of length and if field value if not a number in Siebel

You can use below eScript on Pre Set Field Value (recommended) or Set Field Value on Business Component Server Script. if (FieldName = "SSN")  { var SSNNum = this.GetFieldValue("SSN"); var sErrTxt = TheApplication().LookupMessage("User Defined Errors","Wrong SSN"); var result = isNaN(SSNNum);  // is not a number var length = SSNNum.length;  // Length Count if (result) { TheApplication().RaiseErrorText(sErrTxt); } else if (length < "15" || length > "15")  { TheApplication().RaiseErrorText(sErrTxt); } }

How to add confirm message dialog on button click in Siebel Applet Browser Scripts

Background: On some action like button click it is recommended to add confirmation message as user might accidentally click the button and operations starts or change the value of field based on which some action happen like a trigger. Process: Add below script Applet Browser Script, compile and generate browser scripts and test. function Applet_PreInvokeMethod (name, inputPropSet) {    if(name == 'NewRecord')    {       if(confirm("Are you sure you want to create a new record??"))          return ("ContinueOperation");       else          return ("CancelOperation");     } return ("ContinueOperation"); }   Change the method name and message as per your need. Note: On every compilation you will need to regenerate the browsers scripts and place on web server path.

How to get Parent BC Field Values from Child BC through BC Server Script in Siebel

By using ParentBusComp Method you can get Parent BC field value from Child BC server script, given that in BO there must be link between Parent and Child BC. (ParentBusComp returns the parent (master) business component when given the child (detail) business component of a Link.) I have written below eScript on Child BC for getting Parent BC field value, Parent BC fields should be forced active or you have to active them in eScript using ActivateField(). var ParBC = TheApplication().ActiveBusObject().GetBusComp("ChildBC Name").ParentBusComp(); var FCASE_ID = ParBC.GetFieldValue("Id"); Source: https://docs.oracle.com/cd/B40099_02/books/OIRef/OIRefInterfaceRef117.html

The specialized method '%1' is not supported on Business Component '%2' used by Business Object '%3'.(SBL-DAT-00322) in Siebel

Steps on which received Error: 1. Created new button with method name Validate. 2. Set the Applet user property CanInvokeMethod: Validate to TRUE 3. Called a workflow through applet eScript (on WebApplet_InvokeMethod) Error: When click on the button received below error: The specialized method '%1' is not supported on Business Component '%2' used by Business Object '%3'.(SBL-DAT-00322) Solution: Add CancelOperation for your method on Business Component eScript (on BusComp_PreInvokeMethod) if(MethodName == "Validate") { return (CancelOperation); }