Showing posts with label Siebel eScript - Code Snippets. Show all posts
Showing posts with label Siebel eScript - Code Snippets. Show all posts

Tuesday, April 12, 2011

Business Component - PreWriteRecord Event

Business Requirement: 
Create an Opportunity and step off the record. An error message should be thrown if the Probablity of the Opportunty is 0% and Sales Cycle is blank.
Solution:

Where to put the code:
@ Business Component level we are writing the code proactively,
as this is validation at record level we decided to put the code at Pre event...

function BusComp_PreWriteRecord ()

{

var prob; // declaring the objects

var sales; //declaration again

prob = this.GetFieldValue("Primary Revenue Win Probability");

sales = this.GetFieldValue("Sales Stage");


if(prob == '0' && sales == '' )

{

TheApplication().RaiseErrorText("Percentage should be greater than 0 and Sales Stage should not be blank");

}

}

Compile and test!!!


BusComp_PreWriteRecord Event : Called before a row is written out to the database.
This event can perform any final validation necessary before any internal record-level validation is performed.
 
CAUTION: Take caution when using the Raise Error and RaiseErrorText methods in
BusComp_PreWriteRecord, because they cancel operations. For example, if RaiseErrorText is used in
BusComp_PreWriteRecord, the user or code will not be able to step off the current record until the
condition causing the RaiseErrorText method to be invoked is addressed.

Wednesday, March 16, 2011

A Service Request cannot be closed without filling in comments in the Summary control.

Before I start about the following post, I would like to extend my deep sympathy towards the Japanese people who are stuck by the disaster and am continuously keeping them in my prayers.

 Requirement : A Service Request cannot be closed without filling in comments in the Summary control. An error message should be thrown "Please enter Summary information before closing the Service Request."


Solution:
We solve this problem by using PreWriteRecord event which is called before a row is written to the database.
The event can perform any final validation necessary before any internal record-level validation is performed.

function BusComp_PreWriteRecord ()

{

 var Status=this.GetFieldValue("Status");

var Abstract=this.GetFieldValue("Abstract");

if (Status == 'Closed')

{

if (Abstract=='')

{

TheApplication().RaiseErrorText("If Status is closed then Summery must be entered");

}

}

}

Followers

Search This Blog