Wednesday, July 2, 2008

Server Script

This is added to constrain the positions that can set an recruit status to an employee and to validate the activities associated with the recruit during the transition of a recruit to an employee :::<<<>>>:::

function WebApplet_PreInvokeMethod (MethodName)

{

if(MethodName == "WriteRecord")

{

var Bo = this.BusObject();

var Bc = Bo.GetBusComp("Employee");

var sType =Bc.GetFieldValue("Employee Type Code");

var RecId =Bc.GetFieldValue("Id");

if(sType != "Recruit-Offsite" && sType != "Recruit-Onsite" && sType != "Recruit-Subcontractor" )

{

var CurrentLogin = TheApplication().LoginName();

var EmpBo = TheApplication().GetBusObject("Employee");

var EmpBc = EmpBo.GetBusComp("Employee");

var PosBc;//for getting position Bc

var b=0;

var isRecord;

var a=0;

var z="";

var pos= new Array();

with (EmpBc)

{

SetViewMode(3);

ClearToQuery();

SetSearchSpec("Login Name",CurrentLogin);

ExecuteQuery();

if (FirstRecord())

{

PosBc = GetMVGBusComp("Position");// this method invokes the position MVG for the employee

}

}

with (PosBc)

{

ActivateField("Name");

ClearToQuery();

ExecuteQuery();

b=CountRecords();

var count1= new Array(b);

if (FirstRecord())

{

for (var i=0;i

{

count1[i] = GetFieldValue("Name");

//The list of all positions will be stored in count1[] array.

NextRecord();

}

}

}

for (z=0;z

{

pos = count1[z]

if(pos == "VP Human Resources" || pos == "Human Resource Manager")

{

var ActBo = this.BusObject();

var ActBc = ActBo.GetBusComp("Action");

ActBc.SetViewMode(3);

ActBc.ClearToQuery();

ActBc.SetSearchSpec("Contact Id",RecId);

ActBc.ExecuteQuery(ForwardOnly);

var co = ActBc.CountRecords();

isRecord = ActBc.FirstRecord();

while (isRecord)

//validating the activities for closed state

{

var ActStatus = ActBc.GetFieldValue("Status");

//var str = "I don't like soggy cereal."

var substr = Clib.strrchr(ActStatus, 'D');

if (substr != "Done")

{ TheApplication().RaiseErrorText("One or more 'Activities' of the recruit is not 'Done'"); }

isRecord = ActBc.NextRecord()

}

pos = null;

return (ContinueOperation);

}

z++;

}

TheApplication().RaiseErrorText("You do not have the permission to change the 'Recruit Type'");

return (CancelOperation);

}

return (ContinueOperation);

}

}

Wednesday, June 25, 2008

Architecture

Browser Script Architecture :::<<<>>>:::





Smart Web Architecture :::<<<>>>:::



The Red Box Highlighted indicates the functional area of the respective

Scripts .Ie.,

The server scripts interact with the lower layers and the Browser scripts interact

with the Upper layer (UI related).

Diagram

Browser Script Editor::::<<<>>>::::










The Browser Script Editor allows you to write and edit JavaScript that runs within the

Client browser.The Edit Browser Scripts option is available by right-clicking Applet, Business

Component, Application, and Business Service object definitions in Tools. You can also access it from View > Editors > Browser Script Editor Menu.

The result takes the form of Applet Browser Script, BusComp Browser Script, and so on. Each of these object types has a set of scriptable events.

Diagram

Customer Scripting Object Types



Theory

Difference Between :::<<<>>:::

Server Scripts

Browser Scripts

Authored in Siebel Tools

Authored in Siebel Tools

Written in Siebel VB or eScript

Written in Java Script

Executes on Siebel Server (for Web Clients)

or on he Client Machine (for Mobile or

Dedicated Web Clients)

Browser Scripts are downloaded to the

client and execute within the Client.

Limited Support for User Interaction Interfaces available for accessing the Siebel

Limited Support for User Interaction Interfaces available for accessing the Siebel

Siebel Server Script

Sort Opty Con based on opty account:::::<<>>:::

function WebApplet_PreInvokeMethod (MethodName)

{

if (MethodName == "SortContact")

{

var OppAccBO = TheApplication().GetBusObject("Opportunity");

var OppAccBC = OppAccBO.GetBusComp("Opportunity");

var ConBC = this.BusComp("Contact");

//var AccntBO = TheApplication().GetBusObject("Account");

//var AccntBC = AccntBO.GetBusComp("Account");

//OppAccBC.ActivateField("Name");

var sOppAccount = ConBC.ParentBusComp().GetFieldValue("Account");

//var sConAccount = ConBC.GetFieldValue("Account");

var morerecs = ConBC.FirstRecord();

var count = ConBC.CountRecords();

with (ConBC)

{

SetViewMode(AllView);

ClearToQuery();

SetSearchSpec("Account",sOppAccount);

ExecuteQuery(ForwardBackward);

ConBC.NextRecord();

}

return (CancelOperation);

}

return (ContinueOperation);

}

Siebel Server Script

Load event in Service request list applet :::::<<>>::::

function WebApplet_Load ()

{

var oFromButton = TheApplication().GetProfileAttr("FromMyAccListAppl");

if (oFromButton == "true")

{

oFromButton = "false";

var oBC = this.BusComp();

oBC.NewRecord(NewAfter);

oBC.ActivateField("Priority");

oBC.SetFieldValue("Priority","2-High");

var oAccBC = oBC.GetPicklistBusComp("Account");

with (oAccBC)

{

ClearToQuery();

SetViewMode(3);

SetSearchSpec("Id",TheApplication().GetProfileAttr("AccountIdForSR"));

ExecuteQuery();

FirstRecord();

Pick();

}

oAccBC = null;

oBC = null;

oFromButton = null;

}

}

Tuesday, June 24, 2008

Siebel Server Script

Go through the code and get logic ::::----:::::


function BusComp_PreQuery ()

{

var PBo=TheApplication().GetBusObject("Position");

var TBo = TheApplication().GetBusObject("Assignment (No Rule Groups)");

var PBc=PBo.GetBusComp("Position");

var TBc=TBo.GetBusComp("Assignment Group");

var Pos= TheApplication().PositionName();

var OBO= TheApplication().GetBusObject("Opportunity");

var Id=TheApplication().LoginName();

var OBC= this;

var ser=NULL;

//OBC.InvokeMethod("RefreshBusComp");

//OBC.ClearToQuery();

OBC.ExecuteQuery();

var View=OBC.GetViewMode();

var TerBc="";

var TerPos="";

var TerName="";

var temp;

var z=0;

var k="";

var m="";

var a=0;

var b=0;

var d=0;

var c=0;

var sear="";

var expr="";

var srcexpr= new Array();

if (View==0)

{

if ((View==0)||(View==3))

{

with (OBC)

{

SetSearchSpec("Primary Sales Rep Login",Id);

ExecuteQuery(ForwardBackward);

return (ContinueOperation);

}

}

}

if ((View==1)||(View==3))

{

if ((Pos=="VP Sales")||(Pos=="Marketing_Offshore"))

{

with (OBC)

{

//expr="[Territory]!=""";

SetViewMode(5);

ClearToQuery();

RefineQuery();

ExecuteQuery(ForwardBackward);

return (ContinueOperation);

}

}

else

{

with(PBc)

{

ActivateField("Name");

ActivateField("Territory");

SetViewMode(5);

ClearToQuery();

SetSearchSpec("Name","'"+Pos+"'");

ExecuteQuery(ForwardOnly);

if (FirstRecord())

{

TerBc = GetMVGBusComp("Territory");

}

var Postn=GetFieldValue("Name");

var Terri=GetFieldValue("Territory");

if ((Postn==Pos)&&(Terri!=""))

{

{

with (TerBc)

{

ActivateField("Name");

//ActivateField("SSA Primary Field");

ClearToQuery();

ExecuteQuery(ForwardOnly);

b=CountRecords();

a=b-1;

var count = new Array(b);

if (FirstRecord())

{

for (var i=0;i

{

// if (GetFieldValue("SSA Primary Field") == "Y")

{

count[i] = GetFieldValue("Name");

var Terr = count[i];

}

NextRecord();

}

}

}

}

{

for (z=0;z

{

if (z==a)

{

srcexpr="[Territory]= '" + count[z] +"'";

k=k+srcexpr+" ";

}

if (z

{

srcexpr="[Territory]= '" + count[z] +"'";

k=k+srcexpr+" or ";

}

z++;

m=srcexpr+" OR "+ k +" ";

}

}

with (OBC)

{

//if (temp!="test")

{

SetViewMode(3);

ActivateField("Territory");

ActivateField("Position");

ser= OBC.GetSearchExpr();

//ClearToQuery();

RefineQuery();

ExecuteQuery();

if (ser=="")

{

//SetSearchExpr(m);

ClearToQuery();

SetSearchExpr(m);

ExecuteQuery();

return (ContinueOperation);

}

{

if (Terr=="")

{

ExecuteQuery();

return (ContinueOperation);

}

if (View==3)

{

var appnd=ser+" AND ("+m+")";

//SetSearchExpr(appnd);

ClearToQuery();

SetSearchExpr(appnd);

ExecuteQuery();

return (ContinueOperation);

}

if (View==1)

{

var appnd=ser+" OR ("+m+")";

ClearToQuery();

SetSearchExpr(appnd);

//RefineQuery();

ExecuteQuery();

return (ContinueOperation);

}

}

}

}

}

}

}

}

//else

{

SetViewMode(5);

ser= OBC.GetSearchExpr();

ClearToQuery();

RefineQuery();

SetSearchExpr(ser);

ExecuteQuery();

return (ContinueOperation);

}

}

Friday, June 20, 2008

Siebel Server Script

This script changes the color and size of the text in one field based on the contents of a second field ::||::|||||:::::::
_____
::||::|||||:::::::
function Applet_ChangeRecord ()
{
var CtrlCurrency = this.FindControl("Currency");
var bcCase = this.BusComp();
var strValue = bcCase.GetFieldValue("Currency");
if (strValue == "USD")
{
CtrlCurrency.SetProperty("FontColor", "#000000");
CtrlCurrency.SetProperty("FontSize", "8");
CtrlCurrency.SetProperty("FontStyle", "Normal");
return ("ContinueOperation");
}// end if
else
{
CtrlCurrency.SetProperty("FontColor", "#ff0000");
CtrlCurrency.SetProperty("FontSize", "12");
CtrlCurrency.SetProperty("FontStyle", "Bold");
}//end else
}


Siebel Browser Script

This snippet of code produces a text box whenever the user selects a closed record ::[:::]::
_____________________________ ::[:::]::
function Applet_ChangeRecord ()
{
var BCServReq = this.BusComp();
var StatusString = BCServReq.GetFieldValue("Status");
if (StatusString == "Closed")
{
TheApplication().SWEAlert("This case is closed.")
}
}

siebel Browser Script

Create new record when the parent field is updated ::
Siebel Browser Script:::
_______________________________________:::

function Applet_ChangeFieldValue (field, value)

{

if (field == "Status")

{

var Svc = TheApplication().GetService("Workflow Process Manager");

var Input = TheApplication().NewPropertySet();

var Output = TheApplication().NewPropertySet();

var Bo = TheApplication().ActiveBusObject();

var Bc = Bo.GetBusComp("Employee");

var RowId = Bc.GetFieldValue("Id");

var sStatus = Bc.GetFieldValue("Status");

if (sStatus != "")

{

Input.SetProperty("ProcessName", "Recruit Activity Automatically Generate");

Input.SetProperty("Object Id", RowId);

Input.SetProperty("Activity Type", sStatus);

Svc.InvokeMethod("RunProcess", Input, Output);

Bo =null;

Bc =null;

RowId =null;

}

}

}




Thursday, February 28, 2008

Scripting Overview

The starting point is a QTP script developed in conjunction with Siebel Test Automation. The user then manually inserts lines of code (calls to subroutines supplied as part of this Technical Note) to represent transaction boundaries and action definitions. Transactions and Actions (often referred to in this Technical Note) are part of LoadRunner terminology. Transactions represent units of actions for which performance characteristics are measured, monitored, and analyzed. An Action is comprised of one or more transactions and represents a unit of iteration during a load test. There are two special action types, vuser_init and vuser_end, each of which gets executed only once during a load test per virtual user. All other actions get executed as many times as the number of iterations specified for the load test.
The subroutine calls manually inserted into the QTP script result in ping commands being sent to the server that represent:
• The start of an action with the action name
• Beginning of a transaction with the transaction name
• End of a transaction with the transaction name
In each case, the web server responds with an OK message which is simply ignored. However, the ping commands have to be sent from a browser different from the one running the Siebel application.
The ping commands appear in the HTTP traffic which gets captured by LoadRunner. The AutoGenerate utility (supplied with this Technical Note) then performs post-processing on the LoadRunner script to identify and replace the ping commands with lr_start_transaction and lr_end_transaction calls that identify a transaction. The AutoGenerate utility also splits up the LoadRunner script into different .c files based on the action definitions in the QTP script.