Wednesday, July 21, 2010

Sample Script2

The following example queries the Contact business component and retrieves the First Name and Last Name of the first contact found:
var ContactBO = TheApplication().GetBusObject("Contact");
var ContactBC = ContactBO.GetBusComp("Contact");
with (ContactBC)
{
ClearToQuery();
SetViewMode(AllView);
var fieldsPS = TheApplication().NewPropertySet();
var valuesPS = TheApplication().NewPropertySet();
fieldsPS. SetProperty("Last Name", "");
fieldsPS.SetProperty("First Name", "");
ActivateMultipleFields(fieldsPS);
ExecuteQuery();
if (FirstRecord())
{
GetMultipleFieldValues(fieldsPS, valuesPS);
var slName = valuesPS.GetProperty("Last Name");
var sfName = valuesPS.GetProperty("First Name");
}
}

Sample Script1

The following Siebel eScript example finds a contact with the Last Name = "Abanilla", and adds a new organization named "CKS Software" to its Organization MVG.
var ok = 0;
var ContactBO= TheApplication().GetBusObject("Contact");
var ContactBC = ContactBO.GetBusComp("Contact");
with (ContactBC)
{
ClearToQuery();
SetViewMode(AllView);
// Searches by Last Name
SetSearchSpec ("Last Name", "Abanilla");
ExecuteQuery();
if (FirstRecord())
{
// Instantiates Organization MVG
var oMvgBC = GetMVGBusComp("Organization");
var oAssocBC = oMvgBC.GetAssocBusComp();
oAssocBC.ClearToQuery();
oAssocBC.SetSearchSpec("Name", "CKS Software");
oAssocBC.ExecuteQuery ();
// Checks if the Organization was found
if (oAssocBC.FirstRecord())
{
// Organization was found
try
{
oAssocBC.Associate(NewAfter);
ok = 1;
}
catch (e)
{
ok = 0;
TheApplication().RaiseErrorText("Error Associating new Organization");
}
} // if oAssocBC.FirstRecord
} // if FirstRecord
} // With ContactBC

Activate Field

You must activate fields using ActivateField prior to executing a query for the business component.
By default, fields are inactive except when:
 They are displayed on the applet and the business component is the instance on which the applet is based.
 They are System fields (which include Id, Created, Created By, Updated, and Updated By).
 Their ForceActive property is set to TRUE.
 The method ActivateField has been invoked with the FieldName.
 They have the Link Specification property set to TRUE.
After fields have been deactivated, the business component must be reexecuted or the application crashes.

How can we set focus on a different applet within a view

Place the following code from where you want the focus to shift.

ActiveApplet = theApplication().FindApplet("WM OFFR Response Lead Form Applet");
ActiveCtrl = ActiveApplet.FindActiveXControl("CallBackRequired");
Activectrl.focus();

Enable button based on position

function WebApplet_PreCanInvokeMethod (MethodName, &CanInvoke)
{
if (MethodName == "DeleteRecord")
{
if (TheApplication().PositionName = 'Siebel Administrator')
{
CanInvokeMethod = "FALSE"
}
return (CancelOperation);
}
}

Named Method

From Siebel 7.7 ownwards there is one more method by which we can invoke a workflow. That way is Siebel business Component user property. You can ‘Named Methodn‘ user property in a BC which can invoke a workflow where n is increment to the last named method user property defined on that BC.

Name: Named Method

Value:[Event Name] , “INVOKESVC”, , “Workflow Process Manager”, “RunProcess”, ‘ProcessName’,[Name of the Workflows] , ‘RowId’, [Row Id Value]Example The below mentioned will invoke a workflow named ‘Example Workflow’ when a new record is created in Example BC.

Name: Named Method 1

Value: “New Record”, “INVOKESVC”, “Example”, “Workflow Process Manager”, “RunProcess”, “‘ProcessName’”, “Example Wrokflow”, “‘RowId’”, “[Id]”

Link Specification

Link Specification property should only be set to True if the field on the BC is used by child BC where:

1. The child BC field references the parent field in the Calculated Value, Post Default Value or PreDefault Value using the syntax: Parent: 'BusComp.Field', 'BusComp.Field'; or

2. The child BC references the parent field in a BC User Property: Parent Read Only Field.

3. If ParentFieldValue function is used to obtain the value of the parent BC field.

How to create BS,MVG,Workflow



http://it.toolbox.com/blogs/siebel-answers/how-to-create-a-business-service-36145


http://it.toolbox.com/blogs/siebel-answers/guide-to-creating-mvgs-36686


http://siebelunleashed.com/how-to-invoke-a-workflow-process/




Unlock Project

his is a sure shot method of unlocking. Login to the Siebel server database with table owner siebel. Unlock the project using a SQL update on the table S_PROJECT. The NAME column of this table has the project name.
Example:
UPDATE siebel.s_project
SET locked_flg = ‘N’
WHERE NAME = ‘Account’;

How to make Field Read only Based on View

The requirement is to make the field read only based on the view so that the people who are assigned to this view using responsibilities are given read or write access.

Example Requirement: Make the field “Status” readonly for the view “Opportunity List Admin View” but all other views should have this field non-readonly.

Without wasting more time here are the steps to achieve this:

In Siebel Tools select the Application in the object explorer.

Select the Application you are using. For Example: Siebel Field Service
Right Click and Edit Server Scripts
Under Application_PreNavigate event set the profile attribute. Look at the code below. ActiveViewName is the profile attribute that is being set. The code will look something like this.
function Application_PreNavigate (DestViewName, DestBusObjName)
{
this.SetProfileAttr(”ActiveViewName”, DestViewName);
return (ContinueOperation);
}


Many people have an argument that it might not be a good idea to define it under the application and instead define this attribute under the View, but I think that it is better to have at the application level as I don’t have to define for multiple views and I can reference it from anywhere. Small scripts won’t affect anything.

Create a calculated field under the BC.
Field Name: CalcReadOnlyFlag
Calculated Value: IIf (GetProfileAttr(”ActiveViewName”) = “Opportunity List Admin View”, “Y”,”N”) where “Opportunity List Admin View” is the name of the view for which you want to make readonly.
Create a BC user property
Name: Field Read Only Field: Status (Name of the field for which you want Read Only)
Value: CalcReadOnlyFlag (This is the calculated field that you created above)

Count Function

Count (“MVL Link”) used as an expression in a calculated field returns the number of records in child BC.

Clib - Time difference

Clib.difftime() Method
Syntax
Clib.difftime(timeInt1, timeInt0)

Parameter Description
timeInt0– An integer time value as returned by the Clib.time() function
timeInt1– An integer time value as returned by the Clib.time() function
Returns
The difference in seconds between timeInt0 and timeInt1.
Example
This example displays the difference in time, in seconds, between two times:
function difftime_Click ()
{
var first = Clib.time();
var second = Clib.time();
TheApplication().RaiseErrorText("Elapsed time is " +
Clib.difftime(second, first) + " seconds.");
}
But often time values are retrieved from the a date column in Siebel database. The value retrieved from cant be used directly and needs some manipulation to fit the format. Below is the snippet of the code used to retrieve date/time from the database and find the difference.

//Get Date value from field
var sDate = oBC.GetFieldValue("Opened Date");
//Assign it to Date Object
var sDate1 = new Date(sDate);
//Convert date object to integer equivalent
var sDate2 = sDate1.toSystem();
//find time difference between current time and date opened in seconds
var sTimeDiff = Clib.difftime(Clib.time(), sDate2);

Query and New buttons are getting disabled on querying for a bad data

Status should be declared inside the if method.Otherwise on clicking Query , it searches for status value when there are no records displayed and hence the error.

Popup Applet on clicking Submit Button

Applet1: IDC MNP Export List Applet

ControlValidateRecord
Method Invoked ShowPopup

Control User Prop Mode Edit
Popup IDC MNP_NPR Customer Validation Applet



Applet 2: IDC MNP_NPR Customer Validation Applet
Class CSSSWEFramePopup



Splitting of first name and last name

if ( sMsgCode == "NPR" && sNPRType == "EXPORT")
{
sName = this.GetFieldValue("Name");
sFstname = "";
sLstname = "";
if (sName != "")
{
sNameArray = sName.split(" ");
for (var i = 0; i < sNameArray.length-2; i++)
{
if (sNameArray[i] = "")
sFstname = sFstname + sNameArray[i] + " ";
}
sFstname = sFstname + sNameArray[i];
sLstname = sNameArray[i+1];
this.SetFieldValue("First Name",sFstname);
this.SetFieldValue("Last Name",sLstname);
}

Tuesday, July 20, 2010

Making MVG field Required

Method 1:
Original Field Name: “Dummy Field”
Create a new calculated field with the following details:
Name: “Dummy Field 2″ (We can actually play with Name/Display Name to make it meaningful)

Create a new calculated field with the following details:
Name: “Dummy Field 2″ (We can actually play with Name/Display Name to make it meaningful)

Calculated Value: [Dummy Field]
Force Active: TRUE
Required: TRUE


Method 2:
We can implement this by using the script below. I have tried to set this on a field called, “Dummy Field” for demo:
function BusComp_PreWriteRecord ()
{
var DummyField = this.ActivateField(”Dummy Field”);
DummyField = this.GetFieldValue(”Dummy Field”);
if ((DummyField == “”)||(DummyField == null))
TheApplication().RaiseErrorText(”DummyField is a required field.”);
return (ContinueOperation);
}

LOV Number Limitation

The LookUpValue() function started failing after some particular values. They noticed that after some 12,000 values, the LookUpValue() function no longer worked!
Digging a little more on Metalink, they found that Siebel officially supports only upto a max of 10,000 values in a particular LOV Type. After that, the LookUpValue() function will fail to return a value.

To suppress the opening of the MVG Pop up Applet for a particular Multi Valued Field (MVF)

This could be a requirement in a typical scenario where Siebel OOB offers a Multi Valued relationship, but, we have a requirement where it can possibly have a maximum of one record in the relationship. For eg. Requirements say we can have a maximum of one Address per Account, though Siebel OOB solution offers multiple Addresses per Account. There is no need for the user to be opening the MVG Applet and selecting values from it in this case.
While working to try and find solutions to this problem, we noticed that corresponding to the MVL, there is a property by the name of “Popup Update Only”.
To reach this, navigate to,
Siebel Tools Object Explorer -> Business Component -> Multi Value Link
Query for the Link that you would want to modify. Navigate towards the right in the Records window to locate the Property, “Popup Update Only”. Set this to FALSE. This would be set to TRUE in case we need to pop up the MVG Pop Up window to enter values.
Setting this to FALSE, MVG (Multi Value Group) field values can be edited directly from the Parent Applet.

Siebel Trace

TheApplication().TraceOn method can helps to identify Memory allocated in our scripts and also to identify the SQL that our script is executing.
TraceOn Method Details: Trace method takes 3 arguments
FileName: First argument is the path and filename in which to dump the details
Type: Type arguments tells Trace what kind of details to dump. It can have two values
1. Allocation: which will dump the details of Memory Allocation
2. SQL: Which will dump the SQL’s that are executed in the background by script.
Selection: It is used when you choose type as “Allocation”. It tells Siebel what type of objects should be traced. It can have 3 possible values
1. Script: Traces Scripting objects
2. OLE: Traces objects allocated by automation servers
3. All: Traces both script and Automation server objects
Usage: Below are some examples of using TraceOn Method

TheApplication().TraceOn(“c:\\trace.txt”,”Allocation”,”All”);
Your code that you want to trace Use Trace off when you want to stop the trace
TheApplication().TraceOff();

LookupValue Vs LookupName

The LookUpValue() function in Siebel queries the S_LST_OF_VAL table in Siebel DB with a combination of TYPE and the LIC (Language Independent Code), and returns the Display Value of that particular LOV.

The function LookUpName() queries on S_LST_OF_VAL table with a combination of TYPE and Display Value (or LIC Code too) and returns the LIC Code in return.

How to see hidden object properties in Siebel tools

When you goto Tools->Screen object, you cannot see ‘Bitmap Category’ field because it is HIDDEN in tools for a normal view. You need to enable it from Tools CFG.
Here are steps -
1. Open your Tools.cfg.
2. Search for “ClientConfigurationMode”, it might be there with value like
ClientConfigurationMode = Web
3. If you find it or did’t find it, just add/replace below value to the [Siebel] section of CFG. This is the first section of CFG.
ClientConfigurationMode = All
4. Relaunch your Tools. This will show certain hidden …

To create a view with Visibility Applet Type=Personal

Create Buscomp View mode
BC: Actual KPI
BC View mode:
Name: Personal
Owner Type: Person
Visibility Field: Employee Id

To toggle applets based on the value in a field

Name: KPI Definition Admin List Applet

Applet Toggle:

Applet: KPI Call Plan List Applet/ KPI Dual Visits List Applet/ KPI Field Days List Applet

Auto Toggle Field: Name/ Name/ Name
Auto Toggle Value: Call Plan/ Dual Visit/ Field Days

To create Predefined Queries

1)Goto Administration Application >Predefined Queries
Object: BO Name(NNIO KPI Admin)
Query: 'KPI Definition Admin'.Search = "[Affiliate Name] LIKE ""India"""

2)Goto Query >Save Query as

To change the screen name links in homepage

Goto Administration Application> View links

Unlock a submitted record

function WebApplet_PreInvokeMethod (MethodName)
{
// Created the New button : Unlock. This will change the Status to Planned. So that, the Record is Editable
// We are Invoking a WorkFlow which wil change the Status.

try
{
if(MethodName == "Unlock")
{
var lsCallId = this.BusComp().GetFieldValue("Id");
this.BusComp().ActivateField("NN Unlock Time");
this.BusComp().ActivateField("Calculated Current Time");
var ParseUnlockTime = Date.parse(this.BusComp().GetFieldValue("NN Unlock Time"));
var ParseTodayDate = Date.parse(this.BusComp().GetFieldValue("Calculated Current Time"));
if(ParseTodayDate > ParseUnlockTime)
{
TheApplication().RaiseError("NNIO UnLock Reported Calls");
return(CancelOperation);
}
else
{
// TheApplication().RaiseErrorText("You are allowed to Unlock as it is within the 14 days Timeline");

var bsWrkFlw = TheApplication().GetService("Workflow Process Manager");
var inputs = TheApplication().NewPropertySet();
var outputs = TheApplication().NewPropertySet();
var sWorkflw = "NNIO Unlocking of Reported Calls";
with (inputs)
{
SetProperty ("RowId", lsCallId);
SetProperty ("ProcessName", sWorkflw);
}
bsWrkFlw.InvokeMethod("RunProcess",inputs,outputs);
this.BusComp().InvokeMethod("RefreshRecord");
var llsCallId = this.BusComp().GetFieldValue("Id");
// this.BusComp().ParentBusComp().SetViewMode(AllView);
// this.BusComp().ParentBusComp().ClearToQuery();
// this.BusComp().ParentBusComp().SetSearchSpec("Id", lsCallId);
// this.BusComp().ParentBusComp().ExecuteQuery(ForwardOnly);
this.BusComp().SetViewMode(AllView);
this.BusComp().ClearToQuery();
this.BusComp().SetSearchSpec("Id", lsCallId);
this.BusComp().ExecuteQuery(ForwardOnly);

return (CancelOperation);
}
}
}

catch(e)
{
throw(e);
}

finally
{

ParseUnlockTime = null;
ParseTodayDate = null;
inputs = null;
outputs = null;
bsWrkFlw = null;
sWorkflw = null;
llsCallId = null;
}

}

Import Object

To import and export data from Menu >Import:

Goto Object Explorer in Tools >Import Object >Add the BC for which import option has to be enabled.

Configuring 5 level Hierarchial Picklist

Create
1)Picklist: PickList Country
BC: PickList Hierarchical

2)PickList Brick
PickList District
PickList State
PickList Zone
BC: PickList Hierarchical Sub-Area

Tuesday, July 13, 2010

To ensure uniqueness of records using multiple fields as user keys

Create a field and map it to the User key column:

Name: User Key
Column: NAME (user key column)
PostDefault Value: Expr: "[Name] + [Category] + [Source] + [NNIO Affiliate Name] + [NNIO User Type] + [Status] + [NNIO Sub Target Class]"

To make Comments field read only based on position

Create a Calculated field:Position Flag
Calculated – True
Calculated Value - IIf (GetProfileAttr("Primary Position Type") = "Sales Representative", "Y","N")

Create a BC user prop:
Name: Field Read Only Field: Comments
Value: Position Flag

To make child BC read only

To make child BC read only and disable New button on child BC on clicking submit

Create 2 BC user properties:

1)Name: Aspect Child BC ReadOnly: ReadOnly
Value: BC Read Only Flag

2)Name: Default Aspect
Value: ReadOnly

To make a BC read only on clicking Submit

Create 2 BC User Properties as shown below:
1) Name: Named Method
Value:"Submit", "SET", "Status", "LookupValue(""EVENT_STATUS"", ""Submitted"")"
2) Name:BC Read Only Field
Value: BC Read Only Flag


Create a Calculated field: BC Read Only Flag
Calculated - True
Calculated Value - IIF([Status] = LookupValue ("EVENT_STATUS", "Submitted"),'Y','N')