28
Scripting Questionnaire 1. What are scripting rules ? Ans: Step 1: Declare all configuration possibilities by using tools if it is not possible at that time only u will go for scripting Step 2: Determine where to put script in which Object Step 3: Determine where to put script in which event Step 4 : Add error handling Template to ur Script Step 5 : User Try – Catch – Final Block Mechanism in ur programming . Step 6: Test Ur Script for debugging 2. What is difference between Local variable, module variable and Global Variable in eScript? Ans : Local Variables Local variables defined within a Siebel script are the lowest level of variable scoping. These variables are declared using the Dim statement in Siebel VB or the var statement in Siebel eScript, and their values are accessible only within the script in which they were defined. Module Variables Module variables defined in the (general) (declarations) section of a Siebel object (such as an applet or business component) are the next level of variable scoping. These variables are available as long as the object is instantiated and the values are accessible to scripts in the same object or module.Use Dim statements (for VB) or var statements (for eScript) in the (general) (declarations) section to declare module variables. Global Variables The global variables exist at the highest level. You must declare these variables in every module that needs to access their values. Use the Global statement to declare

Scripting Interview Questions (2)

Embed Size (px)

DESCRIPTION

Siebel Interview

Citation preview

Scripting

Scripting Questionnaire

1. What are scripting rules ?

Ans:

Step 1: Declare all configuration possibilities by using tools if it is not possible at that time only u will go for scriptingStep 2: Determine where to put script in which Object

Step 3: Determine where to put script in which event

Step 4 : Add error handling Template to ur Script

Step 5 : User Try Catch Final Block Mechanism in ur programming .

Step 6: Test Ur Script for debugging

2. What is difference between Local variable, module variable and Global Variable in eScript?

Ans : Local VariablesLocal variables defined within a Siebel script are the lowest level of variable scoping. These variables are declared using the Dim statement in Siebel VB or the var statement in Siebel eScript, and their values are accessible only within the script in which they were defined. Module Variables

Module variables defined in the (general) (declarations) section of a Siebel object (such as an applet or business component) are the next level of variable scoping. These variables are available as long as the object is instantiated and the values are accessible to scripts in the same object or module.Use Dim statements (for VB) or var statements (for eScript) in the (general) (declarations) section to declare module variables. Global Variables

The global variables exist at the highest level. You must declare these variables in every module that needs to access their values. Use the Global statement to declare these variables. Avoid using global variables to store Siebel objects such as BusComp and BusObject.

3. what is use of this object and with Object in eScript?

Ans:

The special object reference this is eScript shorthand for the

current object. You should use it in place of references to active business objects and components.

For example, in a business component event handler, you should use this in place of ActiveBusComp,

With :An Object with which we wish to use multiple methods

4.what is difference between Broser script and server script ?

Browser script is recommended for:

Communication with the user

Interaction with desktop applications

Data validation and manipulation limited to the current record

Server script is recommended for:

Query, insert, update, and delete operations

Access to data beyond the current record

5.How u will test ur scripting Code ?

Ans:Using Siebel debugger u can test ur script code Breakpoints

A breakpoint is a marker on a line of Siebel code that tells the interpreter to suspend execution at that line so that the state of the program can be examined using the Debugger. There are two ways to set breakpoints on lines of Siebel code when editing, and there is an additional way to set a breakpoint when debugging.

Variable Window

The variable window displays the contents of the variables associated with a Siebel script when debugging. It also shows business components, field values, and heretical structures such as property sets.

Siebel Calls Window

The Calls window contains a list of subroutine and function calls that were executed prior to the current line. To access the Calls window, click the Calls button in the Debugger toolbar when you are running the Debugger. A typical Calls window may contain several lines, one for each subroutine entered into and not yet completed.

6.What is difference between Object Type, Event and method?

Ans :

Object : Object is nothing but like a 1. Application

2. Applet

3. Business Component

4. Business Service Event : event is resides in Particular Object

Method : we can use particular object methods in writing a script

7.Give Some Examples of Application Events?

Application_Close Event Application_InvokeMethod Event

Application_Navigate Event

Application_PreInvokeMethod Event

Application_PreNavigate Event

Application_Start Event8.Give some Examples of BC events? BusComp_Associate Event BusComp_ChangeRecord Event

BusComp_CopyRecord Event

BusComp_DeleteRecord Event

BusComp_InvokeMethod Event

BusComp_NewRecord Event

BusComp_PreAssociate Event

BusComp_PreCopyRecord Event

BusComp_PreDeleteRecord Event

BusComp_PreGetFieldValue Event9.What is the usage of Forward Backward And forward only contacts in search methods ?

Ans :

ForwardBackward. Selected records can be processed from first to last or

from last to first. This is the default if no value is specified.ForwardOnly. Selected records can be processed only from the first record

to the last record. Focus cannot return to a record.

10.What are some benefits of using declarative alternatives to scripting?

Ans:

Address common requirements as configurable options. Has undergone performance testing. Is easier to maintain and upgrade. Avoids cost associated with scripting.

Scenarios

Scenario : 1

i want One custom control On Applet Like " My Account " . Whenever I will click that Control Button account based on the location it should display All Values

Solution:

Step 1: create One control in applet Level and set properties like method Invoke is " My Account"

Step 2: compile ur srf and open ur application the button will appear in disable State .

step3 : now u have to enable the button for that purpose write a script in web

applet_PreCanInvoke Method event

Function web Applet_precan Invoke Method ( MethodName, &Can Invoke)

{

if (method name == " My Account")

{

Can Invoke = "TRUE ";

return(cancel operation);

}

return ( Cancel Operation)

}

Step 4: now u want to diaplay locations based on accounts then write code in web applet

pre invoke method event

Function Web Applet_preinvokemethod(MethodName)

{

Switch (Method Name)

{

case "My Account":

var applet = this;

var BC = applet.BusComp( );

var d = Bc.GetFieldValue("Location")

Bc.Clear to Query ( );

Bc.Set Search Spec(" Location", d);

Bc.Execute Query( );

return(Cancel Operation)

break;

}

return ( Continue Operation)

Scenario : 2

How to set Required Filed Property On MVF by using escript?

Solution:

Step 1: identify MVF in any BC and Call that MVF into script

Step 2: write A Code in BC Object and event is Bus Comp _ Pre Write Record Event

function BusComp_Pre Write Record ( )

{

var address;

var length ;

adrress = this.GetFieldValue(" personal street address");

length = address.length;

if (length == 0)

{

the application.RaiseErrorText ( "enter a Value")

}

return(Continue Operation)

}

Scenario 3:

if u Create one New Record in Account an Activity record should be create for that Account

Solution :

write a code in BusComp_NewRecord Event

function BusComp_Newrecord( )

{

var oAction Bc;

var oAccount Bc;

var oAccount Bo;

oAccount Bo = the Applicatio( ).get Busobject(" Accont");

var sAccount RowId = this.get FieldValue("Id");

oAction Bc = oAccount Bo.GetBusComp(""Action")

with (oAction Bc)

{

Activate field("Display")

'' ("Row States Old")

'' ("Type")

'' ("Account Id")

'' ("Account Name")

}

NewRecord(New Before)

SetFieldValue("Type", "ToDo");

'' ("Display","Activities");

'' ("Account id","SAccount Row Id");

write Record( );

}

oAction Bc = null;

oAccount Bo = null

Scenario 4:

i want check the date filed in account Applet if it is more than today's date display error message to the user ?

solution:

step1 : create One date Function Like "Check Date" in General in scripting . Because this

Function we can use any event of that particular object.

step2: write a code in General in serverside script

function CheckDate(sValue,sField)

{

try

{

var sdate;

var ddateofbirth;

var ndateMS;

var dtoday;

var ntodayMS;

var sreturn = 'N';

if (sFiled == "Birth Date")

{

sdate = sValue;

ddateofbirth =newdate(sdate);

ndateMS = ddateofbirth.gettime( ); dtoday = newdate( );

ntodayMS = dtoday.gettiem( );

if (ndateMS > = ntodayMS)

{

sreturn ='Y';

}

}

}

catch(e)

(

throw(e)

}

finally

{

}

return(sreturn)

}

Step 4: write code in BusComp_PreSetFieldValue Even For Chequeing the Field with the

ChequeDate Function

function BusComp_PreSetFieldValue (FieldName, FieldValue)

{

try

{

switch (FieldName)

{

case 'Birth Date':

var DATEMSG = "RAC: Invalid Date of birth entered. Date of birth cannot be post-dated.;

var rtnOldDate = 'N';

var strReturn = ContinueOperation;

oApp = TheApplication();

rtnOldDate = CheckDate(FieldValue);

if (rtnOldDate == 'Y')

{

strReturn = CancelOperation;

throw(DATEMSG);

}

break;

}

}

catch(e)

{

}

final

{

}

scenario 6:

Need to create a button on Contact Form Applet, Name of the button is Cross Sell, when you click on that button it should be pop up an windowPop up Details: That Particular contact is eligible for Cross Sell the other bank products. It should be based on Dont Mail and Dont Call fields.

Conditions:

If Dont Mail is True and Dont Call is False -Contact is eligible for selling Credit Card

If Dont Mail is False and Dont Call is True - Contact is eligible for selling Mutual Funds

If Dont Mail is False and Dont Call is False -Contact is eligible for selling All the Products

If Dont Mail is True and Dont Call is True -Contact is not eligible for selling the Products

The Above messages has to pop up based on the conditions when u clicked on the Cross Sell Button

Solution

Configuration Steps

1. Create one control in applet Level and set properties like method Invoke is " Cross Sell

2. Drag that Control in edit web Layout to control space

3. Compile Ur Srf (Once u will compile u will See only disable state Of control)

Now U want enable the control for that U write a script

Scripting Code: Write In SERVER SIDE

Event : Web applet_PreCanInvoke Method event

Function web Applet_precan Invoke Method ( MethodName, &Can Invoke)

{

if (method name == "Cross Sell")

{

Can Invoke = "TRUE ";

return(Cancel operation);

}

return ( Continue Operation); // Modified Previously it is Cancel Operation //

}

Note : Now u can Visible the Cross Sell Button if u click That button it will throw some error message for that u can write the logic what do u want when u click that button

Scripting Code WRITE IN SERVER SIDE

Function Web Applet_preinvokemethod(MethodName)

{

// Declare All variables Here //

var applet = this;

var BC = applet.BusComp( );

var Rented = Rented;

var null = Null;

var a = Bc.GetFieldValue("Residence Type");

var b = Bc.Get FieldValue(Monthly Income);

var c = Bc.Get FieldValue(Delinq);

var d = Bc.Get FieldValue(BlackListed);

var e = Bc.Get FieldValue(Returned Chq);

var f = Bc.GetFieldValue(Have Car);

var g = Bc.GetFieldValue(Salary Amt);

var h = Bc.GetFieldValue(Salary Transfer);

var i = Bc.GetFieldValue(Phone Bank);

var m = Bc.GetFieldValue(ATM Card#);

var n = Bc.GetFieldValue(Net Bank);

var o = Bc.GetFieldValue(External Bank Credit Card);

var p = Bc.GetFieldValue(Freq Flyer);

var mes1 = If house is rented and average income is above 1000 Jds offer

housing loan (not delinquent nor black listed, nor has any

returned cheques) ;

var mes2 = If contact has any loan and is not delinquent nor blacklisted nor has

returned cheques due to insufficient balance and does not have a

credit card offer credit card ;

var mes3 = If contact does not own a car and income or salary transfer is

above 500 JDs offer a car loan(not delinquent nor black listed, nor

has any returned cheques);

var mes4 = If contact does not have phone or internet or ATM offer the channels ;

var mes5 = If primary card and does not have secondary cards offer supplementary card (not

Delinquent nor black listed, nor has any returned cheques) ;

var mes6 = If internet banking offer internet banking credit card (not delinquent nor black listed,

nor has any returned cheques) ;

var mes7 = If he/she has a credit card from another bank offer our credit card (not delinquent

Nor black listed, nor has any returned cheques) ;

var mes8 = If he/she are a frequent flyer and does not have a credit card offer credit card (not

Delinquent nor black listed, nor has any returned cheques) ;

if (Method Name = = Cross Sell)

{

else if (a == Rented && b > 1000 && c == N && d == N && e == 0)

{

The Application.RaiseErrorText (mes1);

return(CancelOperation);

}

else if (f == N && g > 500 && h == N && c == N && d == N && e == 0);

{

{

The Application.RaiseErrorText (mes2);

return(CancelOperation);

}

else if (i == N);

{

{

The Application.RaiseErrorText (mes3);

return(CancelOperation);

}

else if (m == Null);

{

{

The Application.RaiseErrorText (mes4);

return(CancelOperation);

}

else if (n == N);

{

{

The Application.RaiseErrorText (mes5);

return(CancelOperation);

}

else if (o == Y && c == N && d == N && e == 0);

{

{

The Application.RaiseErrorText (mes6);

return(CancelOperation);

}

else if (p == Y && c == N && d == N && e == 0);

{

{

The Application.RaiseErrorText (mes7);

return(CancelOperation);

}

else if (n == Y );

{

{

The Application.RaiseErrorText (mes8);

return(CancelOperation);

}

}

return ( Continue Operation)

}

Scenario 7

How Can You Set a Multi-value Group Record as Primary Through Siebel eScript?

Solution

1. business component.

Use the BusComp.SetFieldValue method.

2. Commit the change on the parent business component.

Use the BusComp.WriteRecord method

NOTE: The WriteRecord method must be invoked on the parent business component, not on the MVG business component, because the foreign key belongs to the parent record.

For further information and examples of all of Setting the primary record for a multi-value group (MVG) is part of the base functionality in Siebel applications. This can be configured to be set automatically through the Auto Primary property for a multi-value link, or it can be directly selected by the user in the MVG applet.

A special field called SSA Primary Field is used in the Siebel application user interface (UI) to allow users to view and modify the primary record in a MVG applet. The SSA Primary Field belongs to the System category and is not visible in the Siebel Tools Object Explorer or Object List Editor; however, it may be referenced as an applet list column in MVG applets. You can set the SSA Primary Field through Siebel VB or eScript, as long as it is defined in the MVG applet. This allows you to take advantage of the UI context to mimic the end-user manipulation of the primary value in a MVG.

NOTE: Because this approach requires that a UI context be available, it is not available through a COM Data Server interface or other interfaces which do not include a UI context.

The following example outlines a suggested process, and the recommended methods to use in order to set a child record as primary through Siebel VB or eScript:

3. Get the MVG business component.

Use the BusComp.GetMVGBusComp method

4. Set the search criteria to select the appropriate record as primary.

Use the BusComp.ActivateField method to activate any fields needed in your query. NOTE: It is not necessary to activate the SSA Primary Field.

Use the BusComp.SetSearchSpec method to set the appropriate search criteria

5. Perform a query on this business component.

Use the BusComp.ExecuteQuery method.

6. Navigate to the desired primary record.

Use the BusComp.FirstRecord and BusComp.NextRecord methods.

Set SSA Primary Field to "Y" on the MVG these methods, refer to the following manuals in Siebel Bookshelf version 7.7:

Configuring Siebel eBusiness Applications > Configuring Links > Configuring the Primary ID Field

Siebel Object Interfaces Reference > Interfaces Reference > Business Component Methods

Scenario 8

How Can You Display a Message from a Server Script on the Browser?

Ans:

Interactive dialog boxes are features that belong to the JavaScript language and can only be launched from browser script. A server script cannot call functions written on the browser side.

The Application.RaiseError and Application.RaiseErrorText server methods allow the display of a message on the browser side. However, because either of these methods will raise an exception and cancel the execution of the server script, they are not ideal methods for displaying informational messages to the end user.

Although communication originating from a server script is not feasible, it is possible to pass information between browser and server via profile attributes, using the Application.SetProfileAttr and Application.GetProfileAttr methods.

To display a message on the browser side when the server script runs, it is possible to implement a solution using this derived way of communication. The idea is to execute a function recursively on the browser side, using a setTimeout JavaScript function, that scans a specific profile attribute to see if a message is to be displayed. While this script runs on the browser side, the server script can set the profile attribute, so that the browser script will display the contents of the profile attribute in an alert box.

This solution will affect performance, especially on the browser side, so it is advised to launch it only when necessary and stop when it is no longer needed. Additional notes regarding this solution are in the Notes section following the example.

Example

The following example demonstrates a business service called ServerAlerts which checks to see if an alert needs to be displayed, and if so, displays the alert to the user.

1. Create a new business service and add the following browser script to the section:

2. General Declaration

3. var allowScanningServerAlerts = false;

4. function ScanServerAlerts()

5. {

6. var message = theApplication().GetProfileAttr("Alert");

7. if(message != "")

8. {

9. alert(message);

10. theApplication().SetProfileAttr("Alert", "");

11. }

12. if(allowScanningServerAlerts)

13. setTimeout("ScanServerAlerts()", 100);

14. }

15. Add the following browser script to the PreInvokeMethod of the business service:

16. function Service_PreInvokeMethod (methodName, inputPropSet, outputPropSet)

17. switch(methodName)

18. {

19. case "AllowServerAlerts":

20. if(inputPropSet.GetProperty("Value") == "TRUE")

21.

{

22.

allowScanningServerAlerts = true;

23.

theApplication().SetProfileAttr("Alert", "");

24.

ScanServerAlerts();

25.

}

26.

else

27.

allowScanningServerAlerts = false;

28.

return ("CancelOperation");

29.

break;

30. default:

31.

return ("ContinueOperation");

32. }

33. }

34. Add the following browser script to the object within the application that will enable and disable the alerts:

Script for enabling the alerts:

varinPropSet = theApplication().NewPropertySet();

varserverAlertsBS = theApplication().GetService("ServerAlerts");

inPropSet.SetProperty("Value", "TRUE");

serverAlertsBS.InvokeMethod("AllowServerAlerts", inPropSet);

Script for disabling the alerts:

varinPropSet = theApplication().NewPropertySet();

varserverAlertsBS = theApplication().GetService("ServerAlerts");

inPropSet.SetProperty("Value", "FALSE");

serverAlertsBS.InvokeMethod("AllowServerAlerts", inPropSet);

Scenario 9:

How can I toggle applet through script?Ans:

If you have set up a view with manual toggle applets, there may be cases when you need to toggle between applets as part of a script. This can be achieved by using the ToggleTo method in the manner outlined below. Note that this technique should only be used if the applet is set up for the user to manually toggle the applets. It should not be used to execute a toggle when the applets are set up with dynamic toggle.

The following code should be added to the browser script. Usually it will go in the Applet_PreInvokeMethod() event, but it could be placed in a different event depending upon the specific requirements.

// Create new property setvar propSet = TheApplication().NewPropertySet();

// Set the parameters required for the ToggleTo methodpropSet.SetProperty("SWESeq", TheToggleObjectSequenceNum);

// Invoke the ToggleTo method from the applet.applet.InvokeMethod("ToggleTo",propSet);

The code works as follows:

1. In the first line, a new property set object is created to pass the parameters required by the ToggleTo method.

2. In the second line, the SWESeq parameter is set. It is required by the ToggleTo method, and the value is the sequence number of the toggle applet expressed as a string, for example, "1". To determine the sequence number for the desired applet, look in Siebel Tools. Query for the main applet and then open the Object Explorer to expose theApplet Toggle object. The Applet Toggle object contains a Sequence Number property; this is the value to be used in the property set.

3. In the third line, the ToggleTo method is invoked with the property set.

Note that when applets are toggled, the entire view will reload. Therefore, it is not recommended to use this method to toggle more than one applet at the same time, as it might cause instability in the application.

For details on the ToggleTo method, refer to one of the following references, depending upon your current version of Siebel eBusiness Applications:

Scenario 10

How Can I Add Hidden Fields to List Applet for Browser Script Access?

Ans:

Background:

A common business requirement is to have access to business component fields using browser script, but ensuring that these fields are not visible by the end users. In Siebel Versions 7.5.X and 7.0.X only, fields existing on the UI are available to the browser script GetFieldValue()/SetFieldValue() business component methods, regardless of the Force Active value set for those fields.

Moreover, the ActivateField() method is NOT supported for browser script unless used as part of a BC search, before ExecuteQuery and after ClearToQuery.

Solution:

1. Add hidden controls to the applet.

2. The controls have to use the HTML Type: Hidden and must point to the required field using the Field property.

Note: Do not set the 'Visible' property to FALSE. When the 'Visible' property is set to FALSE, the field value will not load to the browser, hence the value is not available for the browser script.

Related issue:

The above solution does not work for list applets, hence when a column is added to the list it is visible to the end user regardless of the HTML Type defined. The end user can also use the display column functionality to remove the column from the list. As result the field is not available for the browser script.

Solution:

1. Create a control mapped to the field and set the HTML Type to Hidden.

2. Add the control to the button bar of the applet.

The solution ensures that the hidden field values are available to the browser script but are not visible to the end user.

This solution can be used in Form applets as well as list applets, avoiding having empty spaces on the applet (where the hidden controls are added).

Scenario 11:

How can users use the GotoView method and maintain view context?

Ans:

The GotoView method can be used for navigating to different views from scripts. The default behavior of GotoView is to place the cursor (focus) on the first record in the view.

When the script is required to get a specific record in focus the method can be executed with business object parameter. The business object is then used to get a business component (BC), on which a query is executed putting the required record in focus.

Example:eScript:// Get the Account business objectvar AccountBO = TheApplication().GetBusObject("Account"); // Get the Account business componentvar AccountBC = AccountBO.GetBusComp("Account");with(AccountBC){// Clear to queryClearToQuery();// Set the required search specificationSetSearchSpec("Id",TheRequiredAccountId);// Execute queryExecuteQuery();}// Call the GotoView Method with business object parameter.TheApplication().GotoView(TheDestinationViewName,AccountBO);

Scenario 12:

How can users dynamically inactivate button when no records are displayed in Siebel version 7.x?

Ans:

As a workaround WebApplet_PreCanInvokeMethod event script is needed to make the button show up.Example:1. Add a button to an applet, and set the property "Method" = My Method2. Modify WebApplet_PreCanInvokeMethod.

Parameter CanInvoke must return TRUE for the button to be enabled. Otherwise, it will be disabled.

The following sample code is used to enable the button if there are records in the applet. If no records are displayed, the button will be disabled.

function WebApplet_PreCanInvokeMethod (MethodName, &CanInvoke){if (MethodName == "My Method"){// Set Id field to stringvar oBC = this.BusComp();var sId = oBC.GetFieldValue("Id");

// Check value of field Id for current bus compif (sId=="") {// if this is true there are no records in applet. Do not invoke the buttonreturn (CancelOperation);oBC = null;

}else { CanInvoke = "TRUE";return (CancelOperation);}}else return (ContinueOperation);

}

Scenario 13:

Using Immediate Post Changes field property in Siebel 7

Ans:

Siebel 7 has introduced a new field property "Immediate Post Changes" to post field changes immediately to the server.

If "Immediate Post Changes" is set to TRUE, PreSetFieldValue event on the server will be triggered.

If "Immediate Post Changes" is set to FALSE, only the PresetFieldValue event on the Browser will be triggered.

For those fields with a dynamic picklist or multi value fields, PreSetFieldValue event doest not trigger on the browser. This is the expected behavior. A Change request 12-BF7ICN has been logged to include this information in the documentation. For these cases, the code needs to be written on the server.

For those fields with static picklist PreSetFieldValue event will trigger on the server as well as on the browser even if "Immediate Post Changes" is set to FALSE.

Scenario 14:

How can the number of records selected on a multi-value group applet be restricted?

Ans:

Siebel applications provide multi-value group applets (MVG applets) to associate records in many-to-many relationships.

By default, the MVG applets allow users to select multiple records at the same time to be associated with the parent business component. There are occasions where users would need to restrict this selection to a specific number. In those situations Siebel scripting can be used to achieve this functionality.

Selected records are associated to the parent business component when user clicks the Add button on the MVG applet. Script written in the Applet_PreInvoke method could capture the Add action, count the number of records currently selected and abort the Add action if this number is greater than expected.

The following eScript sample code limits the number of records than can be selected at the same time on a MVG Applet to 1.

function Applet_PreInvokeMethod (MethodName){ if (MethodName == "AddRecord") { var oBC = TheApplication().ActiveBusComp(); var nRecords = oBC.FirstSelected(); nRecords = oBC.NextSelected(); if (nRecords == 1) { TheApplication().MsgBox("You cannot pick more than one record"); OBC = null; return (CancelOperation); } oBC = null; } return (ContinueOperation);}

This sample code is provided as a general guideline only. Please refer to Siebel technical documentation for additional information regarding the available methods for applets and business components.