Showing posts with label Scripting. Show all posts
Showing posts with label Scripting. Show all posts

Saturday, February 20, 2010

SetNamedSearch - Cannot be modified through UI

Have you come across a requirement where after reaching a view. You don't want user to do a new query and get all the records. You only want to show those records which user saw first time on reaching to this view.
Though you want to give him a query option to search in the given records first time.

Yes, this can be achieved using SetNamedSearch BusComp Method. 

Let me explain you with the help of a example.
Using a Drilldown, user reached to a All Activities List View where I don't want him to see Confidential Activities. I captured the method Drilldown and the Field name using SWEField property, in the drill down only I put code like

BusComp.SetNamedSearch(searchName, searchSpec)

SetNamedSearch("NotConfidential", "[Confidential] != 'Y'")
GotoView(ViewName, BO instance)

Now even after reaching to the DrillDown View, if user do a null query. He will not be able to see the confidential activities.

It is a search criterion that is not cleared by the ClearToQuery; for example, a predefined query or business component search specification.It can only be modified through script; it cannot be modified through the UI. 

You can retrieve this search specification, use GetNamedSearch metho.

Note: that when a new instance of the BusComp is created, the named search specification is cleared.

Thursday, October 8, 2009

VBscript vs escript


Recently, I have to write a BS in escript which was
originally written in VB Script. Since Siebel provides a utility to convert the
VB Script to escript but that utility has so many limitations.


Siebel provided utility does only syntactically changes in the
code which is quite helpful when you have huge lines of code to convert. But analyzing
the code is helpful because there can be things which you can do using config,
workflows or BRP.


Limitations of the utility:


Utility does not modify things for the explicit conversions
like Str, CInt, Int if used. Utility does


The differences between Siebel escript and VB Script are as
follows:



 


VB Script


escript


Dates


·        
Uses inbuilt function to convert Date to String and vice versa.
For E.g. DateValue, Str, Format

 

·        
It also uses DateDiff function to calculate the difference of
Days


We need to do scripting for conversion between Date to String
and vice versa.

Also to find the difference of the days you can use a calculated
field or script for finding difference between the Dates.


Function Return Values


Function name = value


Function name = return(value)


Error Hander


Always executed


Only executed if error.

eScript has finally block to destroy objects.


True/False


Integer


Boolean


Parameters


All by ref.


Only Complex Object by ref.


Modulus


To get the reminder, use ‘mod’


%


Integer Division


Use back slash ‘\’ for integer division


For every division, use forward slash ‘/’


Script Structure


Function MyFunction() As String

On Error GoTo ErrorHandler

 

  //comments

  //variable declarations

  //Program statements are here

 

ErrorHandler:

//ErrorHandler label and all following code is
here

 

//Object destroys from (just the) error handler
are moved here

 

End Function


function MyFunction()

{

//comments

//variable declarations

try

{

//Normal code goes here

}

catch (e)

{

//Error code goes here

}

finally

{

//Object destroys go here

}

}

 


 


In escript for
explicit conversion, we can use functions like ToInteger(), ToString().


Tuesday, September 22, 2009

Capture Drilldown based on Field

Recently, I come across arequirement where We need to set perform some operation before a user drilldown on field in a List Applet.

Vanilla provides a method Drilldown at applet level which can be captured.
There is no way specified in bookshelf whcih can determine that on which field drilldown has occured.

The problem here is if there are more than one drilldown list column in applet, click on any of them will triger the operatio we need to do.
We have thought to use Application Pre Navigate event but the Drilldown view could also be accessible from normal navigation. The operation ill get performed that tiem also. There will be an overhead code at Application level.

The WOrkaround to the problem is to use the SWEField property passed to the Applet PreInvoke propertyset gives the Id specific to the drilldown field . This value has a specific format which changes from list column to list column and record to record.

For example, in “INS Claims List Applet”:

Claim Number field’s first record on applet will have SWEField value “s_1_2_33_0” while the second will have “s_1_2_33_1” and so on
Assign To field’s first record on applet will have SWEField value “s_1_2_93_0” while the second will have “s_1_2_93_1”.

We can find Control Id for a list column and use the same for condition check as below.

function Applet_PreInvokeMethod (name, inputPropSet)
{
if(name == "Drilldown")
{
//Get SWEField property value
var SWEFieldParts = inputPropSet.GetProperty("SWEField");

// Find last occurrence of “_”
var sLastIndex = SWEFieldParts.lastIndexOf("_");

// Get the Control Id of a list column
var sControlId = SWEFieldParts.substring("0", sLastIndex);

if (sControlId == "s_1_2_33")
{
// Business logic

return ("CancelOperation");
}
}
return ("ContinueOperation");
}

Sharing is the Power