Prototype in Siebel eScript - Part 2

The last example  in prototypes dealt with extending a OOB data type, but that extension was done within the business service itself. Prototype in Siebel eScript can be defined only once and used multiple times, this is better demonstrated with the example below.


Validate whether the given string is a valid email address


Define the prototype to extend the OOB string object, and use it as many times as needed. To achieve this we define the prototype in the Application object.

Go to “Server Scripts” of ‘Siebel Life Sciences’ (or the application that you use), and define prototype.


String.prototype.IsEmail = CheckValidEmail;

Add a function 'CheckValidEmail' to the same application object.


function CheckValidEmail()

    var rEmailPat = /^\w+[\w-\.]*\@\w+((-\w+)(\w*))\.[a-z]{2,3}$/;

    return rEmailPat.test(this);


That's about it! Any string can now be tested for a valid email quickly enough. We will build a test function to demonstrate how this is used:

**Service:** COG Test Email | <strong style="font-size: 15px;">Method:</strong> Service_PreInvokeMethod


function Service_PreInvokeMethod (MethodName, Inputs, Outputs)


var sEmail = Inputs.GetProperty("Email");

Outputs.SetProperty("Valid", sEmail.IsEmail());

return (CancelOperation);


When you run this in the simulator, this should either return a 'true' or 'false' value depending on whether the supplied string is a valid email address.

Now, a bit about how it works.

1. First we define the prototype for the data type string with the statement 'String.prototype.IsEmail = CheckValidEmail'. This statement is executed when the application starts up.
2. The above prototype points to a custom function 'CheckValidEmail'. This function uses a simple regular expression to test the validity of the entered string. It returns a 'true' when the string has the specified regex pattern, false otherwise
3. None of the above has any effect until we actually invoke the 'IsEmail' function. When this function is used against the string object, Siebel checks the prototype since no such function exists OOB
4. Return value from the function denotes whether the string 'sEmail' is a valid email address
Tags :
Comments powered by Disqus

Related Posts

Siebel Custom Functions in TheApplication

If you want to reuse code in Siebel, one of the common practices is to put it away in the business service and invoke those methods.

Read More

Create Quick Data Entry Screens with Screen Flow

The typical “CRM flows” work ok, but there’s always opportunities to make them efficient.

Read More
Scheduling meetings with a large group in

Scheduling meetings with a large group in

Let’s say you are running a webinar that expects at least 20 people across the globe who need to be present for the session, or you have scheduled meetings with a dozen people from the client executive team.

Read More