You are on page 1of 8

24/02/2017 SiebeleScript|SiebelExamplesByAsif

SiebelExamplesByAsif
SiebelCRM,SiebelConguration,SiebelAdministration

SiebeleScript

May26,2011

i
2Votes

*************************************
ServerScrpitUIContext
*************************************

validateAccountName(BusComp_PreWriteRecord)onAccountBC
varmin=5;
varmax=12;
varlen;
varn=0;
varlname=this.GetFieldValue(Name);
varen=lname.length;

if(en<min)
{
TheApplication().RaiseErrorText(Accountnameshouldbemorethan4characters);
}

if(en>max)
{
TheApplication().RaiseErrorText(Accountnameshouldnothavemorethan12characters);
}

varrStrcspn=Clib.strcspn(lname,1234567890);

if(rStrcspn<en)
{
TheApplication().RaiseErrorText(Accountnameshouldnotanynumber);
}

RightClickontheAccountBusinessComponentandCompileIt.

SettheJObFieldValuetoEmployeeWheneveranyNewRecordisCreateonContactBC.
1SelecttheContactBusinessComponentandLocktheit.

2RightandSelectEditServerScriptOption.
https://siebelexamples.wordpress.com/2011/05/26/siebelescript/ 1/9
24/02/2017 SiebeleScript|SiebelExamplesByAsif

2RightandSelectEditServerScriptOption.
3SelectFunction(BusComp_SetFieldValue(FieldName)).
4Writethefollowingscript.
setthejobeldvalue.
vardefJob=Employee;
this.SetFieldValue(JobTitle,defJob);

5RightClickontheContactBusinessComponentandCompileIt.
6OpenSiebelwebclientandgotoConactcreateanewrecordtotestit.

DonotallowtodeletetheaccountifthestatusisActive.
1SelecttheAccountBusinessComponentandLocktheit.
2RightandSelectEditServerScriptOption.
3SelectFunctionBusComp_PreDeleteRecord
4Writethefollowingscript.

functionBusComp_PreDeleteRecord()
{
varstatus=this.GetFieldValue(AccountStatus)
if(status==Active)
{
TheApplication().RaiseErrorText(YoucannotdeletethisaccountasitsaActiveaccount.);

return(CancelOperation);
}
else
{
return(ContinueOperation);
}
}

5RightClickontheAccountBusinessComponentandCompileIt.

Donotallowtochangetheaccountstatusifcurrentvolumeisgreaterthan0.
1SelecttheAccountBusinessComponentandLocktheit.
2RightandSelectEditServerScriptOption.
3SelectFunctionBusComp_PreSetFieldValue
4Writethefollowingscript.

functionBusComp_PreSetFieldValue(eldName,value)
{

if(eldName==AccountStatus)
{
varcVolume=this.GetFieldValue(CurrentVolume);

if((value==Inactive)&&(cVolume>0))
{
TheApplication().RaiseErrorText(Unabletoinactivateanaccountthathasacurrentvolume
greaterthan0);
return(CancelOperation);
}
else
return(ContinueOperation);
https://siebelexamples.wordpress.com/2011/05/26/siebelescript/ 2/9
24/02/2017 SiebeleScript|SiebelExamplesByAsif

return(ContinueOperation);
}
else
return(ContinueOperation);
}

WriteScripttoCallServerScriptonUserDeneBu on.
ServerScriptwithAppletBu on:

1Checkthecurrentvolumneldvalueonthebu onclickusingtheserverscript.

1)GotoAppletQueryforAccountEntryApplet
2)RightClickandEditWebLayoutandDragaMiniBu onfromPale ewindowtoApplet.
3)RightClicktheBu onandgotoPropertywindow.
Changethefollowingperoperties.
CaptionStringOverriden:CheckVolume
Runtime=TRUE
MethodName=CheckVol

4)Savethechangesandclosetheweblayout.
5)NowRightthemethodtoenablethebu ononapplet.
6)RightclickonAccountEntryAppletandclickonEditServerScript.
7)GotoWebApplet_CanPreInvokeMethodandwritethefollowingscript.

//enablethebu ononapplet
if(MethodName==CheckVol)
{
CanInvoke=TRUE;
return(CancelOperation);
}
return(ContinueOperation);

8)Nowwewillbewri ingafunctiontocallonthebu onclick.


9)QueryfortheBusinessComponentAccountandRightClickselectEditServerScript.
10)GotoBusComp_PreInvokeMethodmethodandwritethefollowingscript.

functionBusComp_PreInvokeMethod(MethodName)
{
varvol=this.GetFieldValue(CurrentVolume);

if(vol>0)
{
TheApplication().RaiseErrorText(Volumnexistforthisaccount.Volumn=+vol);
return(CancelOperation);
}
else
{
TheApplication().RaiseErrorText(Volumndoesnotexistforthisaccount.);
return(ContinueOperation);
}
}

*************************************
https://siebelexamples.wordpress.com/2011/05/26/siebelescript/ 3/9
24/02/2017 SiebeleScript|SiebelExamplesByAsif

*************************************
ServerScrpitNonUIContext
*************************************

Donotallowtodeletetheaccountifanopportunityisexistfortheaccount.
1SelecttheAccountBusinessComponentandLocktheit.
2RightandSelectEditServerScriptOption.
3SelectFunctionBusComp_PreDeleteRecord.
4Writethefollowingscript.

TheApplication().TraceOn(c:\temp\opp_trace.txt,Allocation,All);
varreturnCode=ContinueOperation;

try
{
//gettheBOandBCrstfortheOpporunity.
varboOpty;
varbcOpty;
varrowID;
//gettherowid
rowID=this.GetFieldValue(Id);

//createthebusinessobjectusingGetBusObjectmethod.
boOpty=TheApplication().GetBusObject(Opporunity);
bcOpty=boOpty.GetBusComp(Opporunity);

//tracetheoperation
TheApplication().Trace(PreparingQuery);

with(bcOpty)
{
SetViewMode(ViewAll);
ActivateField(AccountId);//mustactivatetheeldbeforethecleartoquerymethod.
ClearToQuery();//clearsthecurrentquery.
SetSearchExpr([AccountId]=+rowID+);
ExecuteQuery(ForwardOnly);
}
TheApplication().Trace(QueryExecuted.);

if(bcOpty.FirstRecord())
{
returnCode=CancelOperation;
TheApplication().RaiseErrorText(OppisexistforthisAccount.Itcannotbedeleted.);
}
else
{
returncode=ContinueOperation;
}
}
catch(e)
{
throw(e);//displayerrormessagetouser
}
nally
https://siebelexamples.wordpress.com/2011/05/26/siebelescript/ 4/9
24/02/2017 SiebeleScript|SiebelExamplesByAsif

nally
{
deletebcOpty;
deleteboOpty;
TheApplication().TraceO();
}
return(returncode);

*************************************
BrowserScrpit
*************************************

**Displaytheconrmationofthechangingtheaccountstatusfromanyothertoactivestatus.
1SelectAppletintheObjectListExpolrer.
2SelectAccountListApplet.
3RightClickontheOpportunityListApplet.
4selectEditBrowserScritp.
5SelectApplet_ChangeRecord.
6Writethefollowingscript.

functionApplet_ChangeFieldValue(eld,value)
{
//varstatus=this.FindControl(AccountStatus);
if(eld==AccountStatus)
{
if(value==Active)
{
varans=conrm(areyousureyouwnattochangestatusofthisaccount);
if(ans==true)
return(ContinueOperation);
else
return(CancelOperation);
}
}
}
7setthecompiledirecotrypathusingViewOptionScripting
browswerscriptcompilationfolder:D:\siebel81\Client\PUBLIC\enu

Ex2BroswerScript
**MakethecontrolsreadonlyontheappletiftheServiceRequeststatusisCancelled.
1SelectAppletintheObjectListExpolrer.
2SelectServiceRequestDetailApplet.
3RightClickontheServiceRequestDetailApplet.
4selectEditBrowserScritp.
5SelectApplet_ChangeFieldValue(eld,value)
6Writethefollowingscript.

if(eld==Status)
{
if(value==Cancelled)
{
vartmp=this.FindControl(CommitTime);

tmp.SetProperty(ReadOnly,true);
https://siebelexamples.wordpress.com/2011/05/26/siebelescript/ 5/9
24/02/2017 SiebeleScript|SiebelExamplesByAsif

tmp.SetProperty(ReadOnly,true);
tmp=this.FindControl(ContactLastName);
tmp.SetProperty(ReadOnly,true);
tmp=this.FindControl(Account);
tmp.SetProperty(ReadOnly,true);
tmp=this.FindControl(Product);
tmp.SetProperty(ReadOnly,true);
tmp=this.FindControl(Description);
tmp.SetProperty(ReadOnly,true);
tmp=this.FindControl(Abstract);
tmp.SetProperty(ReadOnly,true);
}
else
{
vartmp=this.FindControl(CommitTime);
tmp.SetProperty(ReadOnly,false);
tmp=this.FindControl(ContactLastName);
tmp.SetProperty(ReadOnly,false);
tmp=this.FindControl(Account);
tmp.SetProperty(ReadOnly,false);
tmp=this.FindControl(Product);
tmp.SetProperty(ReadOnly,false);
tmp=this.FindControl(Description);
tmp.SetProperty(ReadOnly,false);
tmp=this.FindControl(Abstract);
tmp.SetProperty(ReadOnly,false);
}
}

WriteaBrowserscripttoPromptaMessagetouserontheNewRecordcreationasktoentera
valuetocontinue.(Value:Y||N)
1SelectAppletObjectTypeinOE.
2SelectAccountListAppletinOBLE.
3RightClickonAccountListApplet.
4SelectEditBrowserScript.
5ItwillshowthefunctionsandthreeModesofApplet.
SelectfunctionApplet_PreInvokeMethodandwritethefollowingScript.

functionApplet_PreInvokeMethod(name,inputPropSet)
{
if(name==NewRecord)
{
varans=prompt(YtoCreateRecord&NtoExit\nEnteraValue:);
if(ans==Y)
{
theApplication().SWEAlert(Pleaselltherecords..);
return(ContinueOperation);
}
if(ans==N)
{
alert(OperationCancelled.);
return(CancelOperation);
https://siebelexamples.wordpress.com/2011/05/26/siebelescript/ 6/9
24/02/2017 SiebeleScript|SiebelExamplesByAsif

return(CancelOperation);
}
}
}

WriteaBrowserscripttoPromptaMessagetouserontheNewRecordcreationasktoentera
valuetocontinue.(Value:Y||N)
1SelectAppletObjectTypeinOE.
2SelectAccountListAppletinOBLE.
3RightClickonAccountListApplet.
4SelectEditBrowserScript.
5ItwillshowthefunctionsandthreeModesofApplet.
SelectfunctionApplet_PreInvokeMethodandwritethefollowingScript.

functionApplet_PreInvokeMethod(name,inputPropSet)
{
if(name==NewRecord)
{
varans=prompt(YtoCreateRecord&NtoExit\nEnteraValue:);
if(ans==Y)
{
theApplication().SWEAlert(Pleaselltherecords..);
return(ContinueOperation);
}
if(ans==N)
{
alert(OperationCancelled.);
return(CancelOperation);
}
}
}

CreateaBu ononAppletandExporttoAccountNamestoExcelusingDOMObject.

1SelectAppletObjectTypeinOE.
2SelectAccountListAppletinOBLE.
3RightClickonAccountListApplet.
4SelectEditWebLayout
ItwillshowthefunctionsandthreeModesofApplet.
5SelectEditListModeandAddabu ontoAppletandChangethefollowingproperties;
CaptionStringOverride:Export2Excel
MethodInvoke:Export
Runtime:TRUE.

6Savetheappletandclosetheweblayout.
7SelectAccountListAppletandRightClickSelectEditServerScript.
thisstepwillenablethebu ononapplet.
SelectfunctionWebApplet_CanPreInvokeMethodandwritethefollowingScript.
functionWebApplet_PreCanInvokeMethod(MethodName,&CanInvoke)
{

if(MethodName==Export)
https://siebelexamples.wordpress.com/2011/05/26/siebelescript/ 7/9
24/02/2017 SiebeleScript|SiebelExamplesByAsif

if(MethodName==Export)
{
CanInvoke=True;
return(CancelOperation);
}
return(ContinueOperation);
}
SavethescriptandClosethewindow.
8SelectAppletObjectTypeinOE.
9SelectAccountListAppletinOBLE.
10RightClickonAccountListApplet.
11SelectEditBrowserScript.
12ItwillshowthefunctionsandthreeModesofApplet.
SelectfunctionApplet_PreInvokeMethodandwritethefollowingScript.
WritetheFollowingScript.

functionBusComp_PreInvokeMethod(MethodName)
{
varExcelApp;

if(MethodName==Export)
{

this.ActivateField(Name);
this.SetSearchSpec(Name,*);
this.ExecuteQuery(ForwardBackward);

varcount=this.CountRecords();

ExcelApp=this.COMCreateObject(Excel.Application);
ExcelApp.Visible=true;
ExcelApp.WorkBooks.Add();

this.FirstRecord();

for(vari=1;i<=count;i++)
{
ExcelApp.ActiveSheet.Cells(i,1).Value=this.GetFieldValue(Name);
ExcelApp.ActiveSheet.Cells(i,2).Value=this.GetFieldValue(City);
ExcelApp.ActiveSheet.Cells(i,3).Value=this.GetFieldValue(AccountStatus);
this.NextRecord();
}

ExcelApp.Application.Quit();
ExcelApp=null;
}
return(CancelOperation);

https://siebelexamples.wordpress.com/2011/05/26/siebelescript/ 8/9

You might also like