Documente Academic
Documente Profesional
Documente Cultură
Background
There are instances in which date arithmetic is required to implement certain business
rules. Siebel eScript provides date functions that allow users to build custom functions to
know the difference between two dates, add/subtract a number of days to a date, etc.
This document presents a set of functions that can be used in scripts to implement more
complex business rules.
Sample code provided in this document is provided only as a guideline, and not as a
final product to be used in a production environment. None of the functions
perform any validation (example: daylight savings adjustment) of the input
parameters or error trapping. The code is provided as a start point from which
actual scripts can be built, and is intended to show how some of the functions
provided by eScript can be used to perform more complex tasks.
function DateToString(dDate)
{
// Parameters :
// dDate : Date object
// Returns : A string with the format "mm/dd/yyyy" or "mm/dd/yyyy hh:mm:ss"
function StringToDate(sDate)
{
// Parameters :
// sDate : A string with the format "mm/dd/yyyy" or "mm/dd/yyyy hh:mm:ss"
// Returns : a Date object var ArDateTime = sDate.split (" ");
var ArDate = ArDateTime[0];
var splitDate = ArDate.split ("/");
var nDay = ToNumber(splitDate[1]);
var nMonth = ToNumber(splitDate[0]);
var nYear = ToNumber(splitDate[2]);
if (ArDateTime.length == 1)
return (new Date(nYear, nMonth-1 , nDay))
else
{
var ArTime = ArDateTime[1];
var splitTime = ArTime.split(":");
if (splitTime[0]=="00" && splitTime[1]=="00" && splitTime[2]=="00"
return (new Date(nYear, nMonth-1 , nDay))
else
{
var nHours = ToNumber(splitTime[0]);
var nMinutes = ToNumber(splitTime[1]);
var nSeconds = ToNumber(splitTime[2]);
return (new Date(nYear,nMonth-1,nDay, nHours, nMinutes, nSeconds))
}
}
}
Sample script
The following sample script retrieves the Service Requests that have been opened in the
last 45 days. The code is provided only as an illustration on how the functions can be
used.
FAQ 1554: How to set a multi value group record as primary though
VB/eScript?
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 be directly selected by the
user in the multi-value field.
Sometimes this manipulation must be performed using Siebel eScript or Visual Basic
(VB) code in order to complete an Enterprise Integration Manager (EIM) task. An
example of when this might be needed is when an interface table does not take primaries
into account. An Assignment process may also need to set the primary record via eScript
or VB when the Workflow is not available.
In the table for the Parent Business Component there exists a column with a name like
'PR_*'. This column holds the foreign key which points to the Row Id of the child record
defined as the primary. Siebel Systems does not support directly setting the "Primary
Address Id" Field in the parent Business Component.
The "SSA Primary Field" is used for the primary child implementation. This special field
belongs to the System category and is not visible within Tools. To allow setting it
through VB or eScript, it must first be defined in the multi-value group applet.
In VB or eScript code, it is possible to take advantage of the user interface (UI) context
to mimic the end-user manipulation, using the "SSA Primary Field". From the parent
record, get the MVG business component. On this business component, execute a query
in order to retrieve the child for which the "SSA Primary Field" should be set through a
simple BusComp.SetFieldValue("SSA Primary Field", "Y"). Remember to activate
this field before launching the query.
Note that the commit must be invoked on the parent business component and not on the
MVG business component because the foreign key belongs to the parent record.
FAQ 1977: How to send custom HTTP headers while sending HTTP
request to external Web application through EAI HTTP Transport
business service.
In Siebel version 7.x, EAI HTTP Transport business service allows set-up of custom
HTTP headers while sending outbound requests. These headers might be required to send
additional information to the external Web application.
In order to generate custom headers, users need to set the input properties of the form
HDR.xxx where xxx is the header name. For example, in order to set a custom header
named "Test", input property name should be HDR.Test.
Note: Users cannot set such input property in the workflow process step because a .
(Dot) in the input argument indicates a hierarchy type. Users must write a custom
business service as a wrapper written in Siebel VB or Siebel eScript to set custom
headers and initiate the HTTP request. Users can then call this business service from the
workflow process.
Here is a sample custom business service written in eScript, which sets a custom HTTP
header named "Test" and sets its value to "MyTest".
inp.SetProperty("HTTPRequestMethod","POST");
inp.SetProperty("HTTPRequestURLTemplate","http://localhost/test/test1.asp");
inp.SetProperty("HDR.Test","MyTest");
inp.SetValue("Hello World");
bs.InvokeMethod("Send",inp,out);
return(CancelOperation);
}
else
return (ContinueOperation);
For example:
1. Users can run SmartScripts to create records (for example, service requests).
2. After the record has been created, Dynamic Assignment will automatically run
Assignment Manager.
1. Create assignment rules for Service Request object (for more details about
Assignment rules configuration, refer to Assignment Manager Administration
guide).
2. Create new SmartScript script with following:
1. Question1
Name: SRDescription
Answer Type: String
Answer Control: Default
Save Business
Service Request
Object:
Save Bus Comp: Service Request
Save Field: Description
Translations: English-American
2. Question2
Name: TestQuestion2
Answer Type: RDsr2
Answer Control: RDsr2
Translations: English-American
3. Page
Name: TestPage1
First Question: SRDescription
Translation: English-American
Label: TestPage1
Next Question: TestQuestion2
4. SmartScript
Name: SmartScript_AssignSR
Type: pick any value (Other)
Active: Yes
First Page: TestPage1
Translation: English-American
Smart Script Assign
Label:
SR
3. Go to Smart Script Programs:
SaveBC.ActivateField("Area");
SaveBC.SetFieldValue("Area", "Upgrade");
//*****************
SaveBC.WriteRecord();
var bsAmgr =
TheApplication().GetService("Synchronous
Assignment Manager Requests");
var psInput =
TheApplication().NewPropertySet();
var psOutput =
TheApplication().NewPropertySet();
psInput.SetProperty("AsgnObjName","Service
Request");
//Assignment Object Name
psInput.SetProperty("ObjRowId", myid);
//Object Row ID
bsAmgr.InvokeMethod("Assign", psInput,
psOutput);
//*****************
}
Background
This technical note provides information about creating a shared library on Solaris or
AIX, and accessing it from Siebel eScript. Shared libraries on Solaris are similar to DLLs
on Windows. By implication, the eScript must run within a Siebel Server on Solaris, for
example, a business service called by a workflow process.
Summary
Shared Library
A shared library is a collection of functions that are compiled in a special manner. It does
not contain a main() function. It can be linked to any executable program. The Linker
does not include the code segments to the executable directly, but a path to the code
segment. This implies that the program using shared libraries is smaller than the same
program linked with the static version of those libraries.
Shared libraries are identified by their extension .so whereas static libraries have the
extension .a.
Example: In libtest.c
#include <string.h>
void test(char *c)
{
strcpy(c, "This is a shared library
function");
return;
}
LD_LIBRARY_PATH
The LD_LIBRARY_PATH environment variable defines the path where the Siebel
server looks for the shared library file. After the installation of the Siebel server,
LD_LIBRARY_PATH points to the siebsrvr/lib directory. Copying the custom shared
library file into this directory will mean there is no need to change the
LD_LIBRARY_PATH environment variable.
In HP-UX, SHLIB_PATH environment variable defines the path where Siebel server
looks for most shared library files. When using SElib.dynamiclink in HP-UX, Siebel
will look for the shared library in LD_LIBRARY_PATH environment variable.
eScript provides the SElib.dynamicLink() method to call a shared library file. Please
note that there are some differences between using this method for a Windows dll and a
shared library. There are some parameters, which are not used for shared library. For
example Calling Convention(CDECL, STDCALL..) is not used when calling a shared
library using the SElib.dynamicLink() method.
Example:
//Declare a variable
var s;
//Initialize a variable
s = " ";
Note: There should be no need to specify the complete path for a shared library as
LD_LIBRARY_PATH is already pointing to siebsrvr/lib, and the custom shared library
libtest.so exists in this directory. However, it may be necessary in some instances.
Technical Note 427: HTTP outgoing requests using Siebel Server Scripts
and Browser Scripts
Background
There are some situations where Siebel configurators need the ability to send HTTP
information back to external web systems, via http from within a script to confirm an
order or validate certain operations before the script can continue its normal execution.
There are different approaches to implement HTTP outgoing messages depending on the
type of scripting you have (Browser or Server script) and the type of Siebel client
running the script (Standard or High interactivity modes).
For the case of Browser and Server scripts and High Interactivity mode, users can use the
Siebel EAI HTTP Transport. For Low Interactivity mode, users can opt for a Java Script
based approach. Both these approaches are described in the next section.
Summary
From a scripting perspective, the Siebel EAI HTTP Transport can be used as a business
service providing both GET and POST methods for submitting the information to the
external system. It can be invoked either from Browser or Server script using similar
syntax, with the exception of the business service method invocation, where the Output
property is received differently in the Browser Script. See the examples section for more
details.
Another alternative in Standard Interactivity mode where business services are not
available in Browser Script is to use the Java Script Open method to construct an HTML
page on the fly, which posts the data to the external system.
Sample code
The sample code noted below presents both approaches, on invoking an ASP page and
passing to it two parameters: Data and Source using HTTP POST method.
oInputs.SetProperty("HTTPRequestBodyTemplate", sRequest);
oInputs.SetProperty("HTTPRequestMethod", "POST");
oInputs.SetProperty("HTTPRequestURLTemplate", Url);
Siebel VB approach:
oPostPage.document.write("<\/FORM>");
oPostPage.document.write("<\/BODY><\/HTML>");
If the Siebel application is running in High Interactivity mode the user can also invoke
the EAI HTTP Transport service to post the data, however this feature is not available on
low interactivity mode in which the previous approach cannot be used.
oInputs.SetProperty("HTTPRequestBodyTemplate", sRequest);
oInputs.SetProperty("HTTPRequestMethod", "POST");
oInputs.SetProperty("HTTPRequestURLTemplate", sUrl);
References
For additional information on the HTTP Transport methods please refer to the Transport
and Interfaces: Siebel eBusiness Application Integration Volume III guide, chapter 4
"EAI HTTP Transport".
Technical Note 207: Storing and Calling Global VB Functions Using DLLs
Last Modified: 11 November 1998
Area(s): Siebel VB/eScript/Browser Script/COM
Release(s): V5 (Siebel 99-Enterprise)
Database(s): All Supported Databases
App Server OS(s): All Supported Platforms
Latest release tested
V5 (Siebel 99-Enterprise)
against:
Keywords: Global VB Functions, Using DLLs
Background
Siebel Visual Basic allows developers to create scripts on specific objects within the
repository, but does not directly support script sharing among objects – for example, the
use of global functions and subroutines. For configurations that require complex
functions or subroutines to be called in several different places, making several copies of
a script – one on each associated Siebel object – can present a huge maintenance
challenge.
The Siebel (COM) Application Server makes it possible for configuration teams to store
a function or subroutine in a .dll file and access it from any Siebel application object.
This approach simplifies the maintenance task and helps ensure that future changes to
key scripts are applied consistently throughout the application.
For cases in which the script has already been written in Siebel Visual Basic, the
approach begins with porting it over to a Microsoft Visual Basic .dll file. In order to
access Siebel application data and other state properties, the script will need to activate a
reference to the Siebel Application Server. Using the Siebel application server, the script
can then perform virtually all the same functions as Siebel Visual Basic, with a couple of
minor syntax changes. A few lines of Siebel Visual Basic (SVB) should be added to the
objects within Siebel applications that need to use the function. These will instantiate the
class, execute its methods and destroy it when done.
Summary
Following steps will produce a .dll for storing the global function:
This technical note shows an example that uses a subroutine called "Aggregate" which
takes two arguments: parentfield and childfield. Its declaration appears as:
9. Add the script to be run in the global function. If the script was originally written
inside a Siebel application, be sure to change from "TheApplication.[method]" to
"SiebelApplication.[Method]. Also, keep in mind that "errCode" is a required
argument for Siebel application methods that belong to objects inside the
Application Server. Modify the names of Siebel application object types to
conform to the syntax used by the Siebel Application Server. For example:
Etc.
10. Under the Class Terminate event, add the following line:
11. After writing the function, change the name of the project from the default
"Project1" to something more appropriate (later this will help in referring to the
class object.). To do this, go to the Project Explorer window (this can be accessed
by clicking View > Project Explorer, if it’s not already open). Select the project
object with the default name "Project1." From here, go to the Properties window
and type the name in the "(Name)" property (example: "GlobalFunction")
12. Change the name of the class object to something that’s consistent with its
purpose (example: "StringManager") using the steps outlined above.
13. Compile the .dll file by selecting File > Make Project1.dll. When this item is
selected, a dialog box for saving the .dll file under any name (that is, the name
can be changed from the default "Project1.dll") will be seen. When the name and
location of the .dll file is chosen, click "OK."
14. Save the project and exit Visual Basic.
1. In Siebel Tools, navigate to the object and event from where the script is to be
called.
2. Declare an object variable for referring to an instance of the class using the
syntax:
3. Instantiate the class and set the object variable using the syntax in the following
example:
4. Call the function in the .dll (example: "Aggregate") using the syntax in the
following example:
Example
The code in the following example was designed to concatenate the notes from several
child records into a summary description field of a parent record. The SVB calling this
routine would logically reside on both the WriteRecord and DeleteRecord events of the
child business component, so that any time one of the child records changed, the parent
summary would be updated.
If childbc.FirstRecord Then
Notes = "["
Do
Notes = Notes & Left(childbc.GetFieldValue("Created"), 11) & "]" & Chr(32) & Chr(32)
Exit Do
End If
Loop
parentbc.ActivateField parentfield
parentbc.WriteRecord
parentbc.DeactivateFields
End If
If childbc.FirstRecord(errCode) Then
Notes = "["
Do
Exit Do
End If
Loop
parentbc.DeactivateFields errCode
End If
End Sub
End Sub
End Sub