Wednesday, February 15, 2012

Avoid duplicates using eScript.

To avoid duplication in Contact BC based on First Name and Last Name. If Firstname and LastName already exists then we have to raise a message.

BusComp_PreWriteRecord()
{

var oBO = TheApplication().GetBusObject(“Contact”);

var oBC = oBO.GetBusComp(“Contact”);

With(oBC)

{
SetViewMode(AllView);
ClearToQuery();
SetSearchSpec(“First Name”, this.GetFieldValue(“First Name”));
SetSearchSpec(“Last Name”, this.GetFieldValue("Last Name”));
ExecuteQuery(ForwardOnly);

if (FirstRecord())

{

TheApplication().RaiseErrorText (“Sorry this record exists”);

}
oBC = null;
0BO = null;
return(ContinueOpertion);

}

Compile and test. Please Note :
1. CancelOperation stops the execution of the underlying Siebel code associated with the event.
2. and no need to activate fields as it will be taken care by "SetSearchSpec".

ALSO Please Note:
About ExecuteQuery(ForwardOnly);
Use ForwardOnly Cursor Mode if you will traverse through the record set from FirstRecord using NextRecord and will not return to a previous record. If ForwardOnly cursor mode is not mentioned, it will be defaulted to ForwardBackward and to support this Siebel system has to create a Cache to maintain the entire record which would degrade the performance.

This is particularly true if you perform a look up or if you access a pick list.


Happy eScripting!!!!

3 comments:

  1. I really appreciate information shared above. It’s of great help. If someone want to learn Online (Virtual) instructor lead live training in SIEBEL CRM kindly contact us http://www.maxmunus.com/contact
    MaxMunus Offer World Class Virtual Instructor led training on SIEBEL CRM We have industry expert trainer. We provide Training Material and Software Support. MaxMunus has successfully conducted 100000+ trainings in India, USA, UK, Australlia, Switzerland, Qatar, Saudi Arabia, Bangladesh, Bahrain and UAE etc.
    For Demo Contact us.
    Saurabh Srivastava
    MaxMunus
    E-mail: saurabh@maxmunus.com
    Skype id: saurabhmaxmunus
    Ph:+91 8553576305 / 080 - 41103383
    http://www.maxmunus.com/

    ReplyDelete

Followers

Search This Blog