Here is a good way to invoke a Workflow in asynchronous mode. (Workflow Policies are another option)
var bsSvc = null;
var psInput = null;
var psChild = null;
var psOutput = null;
bsSvc = TheApplication().GetService("Asynchronous Server Requests")
psInput = TheApplication().NewPropertySet();
psChild = TheApplication().NewPropertySet();
psOutput = TheApplication().NewPropertySet();
psInput.SetProperty("Component", "WfProcMgr");
psChild.SetProperty("ProcessName", "Health Plan Process"); //workflow name
psChild.SetProperty("Object Id", ContactId);
psChild.SetProperty("Policy Id", PolicyId);
psChild.SetProperty("OGType", "RatePlan");
psInput.AddChild(psChild);
bsSvc.InvokeMethod("SubmitRequest", psInput, psOutput);
May 21, 2014
April 30, 2014
Executing a SQL through Scripting
Here is the function which takes SQL File Name as imput which is to be executed.
sConnectString = sUserName + "/" + sPswd + "@" + sDBname;
sSQLCommand = "sqlplus" + " " + sConnectString + " @" + vSQLFile;
Clib.system(sSQLCommand);
It looks straight forward but we need to get few important values like SQLFilePath, Username, Password and DBName.
function ExecuteSQL(sqlFileName)
{
try
{
TheApplication().WriteLog("Inside Function ExecuteSQL:Start");
TheApplication().WriteLog("SQL File Name:" + sqlFileName);
var boSysPref = TheApplication().GetBusObject("System Preferences");
var bcSysPref = boSysPref.GetBusComp("System Preferences");
var sqlPath;
var vSQLFile;
var vPropFileName = "/siebel.properties";
//we have stored SQL file path in system preferences
with(bcSysPref)
{
ClearToQuery();
SetViewMode(AllView);
ActivateField("Name");
ActivateField("Value");
SetSearchSpec("Name", "SQLPath");
ExecuteQuery();
if (FirstRecord())
{
sqlPath = GetFieldValue("Value");
}
}
vSQLFile = sqlPath + sqlFileName;
//Read the siebe;.properties file to get Username, Password and DBName
var propertyFileName = sqlPath + vPropFileName;
TheApplication().WriteLog("propertyFileName :" + propertyFileName);
var fp = Clib.fopen(propertyFileName, "r");
var sUserName = "";
var sPswd = "";
var sDBname = "";
var sConnectString = "";
var sSQLCommand = "";
var line;
var Pattern = /\s*$/;
for (line = Clib.fgets(fp); line != null; line = Clib.fgets(fp))
{
var cells = line.split("=");
var sName = cells[0];
var sValue = cells[1];
sName = sName.replace(Pattern, "");
sValue = sValue.replace(Pattern, "");
if (sName == "oracle.siebel.userName")
{
sUserName = sValue;
}
else if (sName == "oracle.siebel.password")
{
sPswd = sValue;
}
else if (sName == "oracle.siebel.db.name")
{
sDBname = sValue;
}
}
//Call to execute SQL
if ((sUserName.length == 0) || (sPswd.length == 0) || (sDBname.length == 0))
{
TheApplication().WriteLog("Insufficient DB connection info");
}
else
{
sConnectString = sUserName + "/" + sPswd + "@" + sDBname;
sSQLCommand = "sqlplus" + " " + sConnectString + " @" + vSQLFile;
Clib.system(sSQLCommand);
}
}
catch (e)
{
TheApplication().WriteLog("Error in function ExecuteSQL:" + e.toString());
}
finally
{
TheApplication().WriteLog("ExecuteSQL:End");
}
}
Amazing! Isn't it? Hope it helps :)
sConnectString = sUserName + "/" + sPswd + "@" + sDBname;
sSQLCommand = "sqlplus" + " " + sConnectString + " @" + vSQLFile;
Clib.system(sSQLCommand);
It looks straight forward but we need to get few important values like SQLFilePath, Username, Password and DBName.
function ExecuteSQL(sqlFileName)
{
try
{
TheApplication().WriteLog("Inside Function ExecuteSQL:Start");
TheApplication().WriteLog("SQL File Name:" + sqlFileName);
var boSysPref = TheApplication().GetBusObject("System Preferences");
var bcSysPref = boSysPref.GetBusComp("System Preferences");
var sqlPath;
var vSQLFile;
var vPropFileName = "/siebel.properties";
//we have stored SQL file path in system preferences
with(bcSysPref)
{
ClearToQuery();
SetViewMode(AllView);
ActivateField("Name");
ActivateField("Value");
SetSearchSpec("Name", "SQLPath");
ExecuteQuery();
if (FirstRecord())
{
sqlPath = GetFieldValue("Value");
}
}
vSQLFile = sqlPath + sqlFileName;
//Read the siebe;.properties file to get Username, Password and DBName
var propertyFileName = sqlPath + vPropFileName;
TheApplication().WriteLog("propertyFileName :" + propertyFileName);
var fp = Clib.fopen(propertyFileName, "r");
var sUserName = "";
var sPswd = "";
var sDBname = "";
var sConnectString = "";
var sSQLCommand = "";
var line;
var Pattern = /\s*$/;
for (line = Clib.fgets(fp); line != null; line = Clib.fgets(fp))
{
var cells = line.split("=");
var sName = cells[0];
var sValue = cells[1];
sName = sName.replace(Pattern, "");
sValue = sValue.replace(Pattern, "");
if (sName == "oracle.siebel.userName")
{
sUserName = sValue;
}
else if (sName == "oracle.siebel.password")
{
sPswd = sValue;
}
else if (sName == "oracle.siebel.db.name")
{
sDBname = sValue;
}
}
//Call to execute SQL
if ((sUserName.length == 0) || (sPswd.length == 0) || (sDBname.length == 0))
{
TheApplication().WriteLog("Insufficient DB connection info");
}
else
{
sConnectString = sUserName + "/" + sPswd + "@" + sDBname;
sSQLCommand = "sqlplus" + " " + sConnectString + " @" + vSQLFile;
Clib.system(sSQLCommand);
}
}
catch (e)
{
TheApplication().WriteLog("Error in function ExecuteSQL:" + e.toString());
}
finally
{
TheApplication().WriteLog("ExecuteSQL:End");
}
}
Amazing! Isn't it? Hope it helps :)
January 24, 2014
Calculating Earliest Start Date and Latest End Date using MVL & MVF
Recently I had a Requirement where in I have a Parent BC and a Child BC. Child BC has records with "Start Date" and "End Date". Each record has different start and end dates. Parent BC has Earliest Start Date and Latest End Date fields.
What I had to do was, find the least of the Start Dates and max of the End Date from the child and populate them at Parent BCs Earliest Start Date and Latest End Date fields.
For determining Earliest Start Date and Latest End Date, as always first thought that came into my mind was achieving this using Scripting :) But I found a better configuration.
Here is what you have to do.
In the Parent BC:
Create a MVL "Parent Child MVL" between Parent and Child BC. (Link between these BCs must have been there)
Create 2 MVFs =======>
Name: Start Date MVF
MVL: Parent Child MVL
Destination Field: Start Date
Type: DTYPE_DATE
Name: End Date MVF
MVL: Parent Child MVL
Destination Field: End Date
Type: DTYPE_DATE
Create 2 calculated fields =======>
Name: Earliest Start Date Calc
Calculated Value: Min ([Start Date MVF])
Type: DTYPE_DATE
Name: Latest End Date Calc
Calculated Value: Min ([End Date MVF])
Type: DTYPE_DATE
You are ready! You can add a small code to read these Calc fields and populate the Parent BC fields Earliest Start Date and Latest End Date! (there might be a better way though)
Siebel is awesome :)
What I had to do was, find the least of the Start Dates and max of the End Date from the child and populate them at Parent BCs Earliest Start Date and Latest End Date fields.
For determining Earliest Start Date and Latest End Date, as always first thought that came into my mind was achieving this using Scripting :) But I found a better configuration.
Here is what you have to do.
In the Parent BC:
Create a MVL "Parent Child MVL" between Parent and Child BC. (Link between these BCs must have been there)
Create 2 MVFs =======>
Name: Start Date MVF
MVL: Parent Child MVL
Destination Field: Start Date
Type: DTYPE_DATE
Name: End Date MVF
MVL: Parent Child MVL
Destination Field: End Date
Type: DTYPE_DATE
Create 2 calculated fields =======>
Name: Earliest Start Date Calc
Calculated Value: Min ([Start Date MVF])
Type: DTYPE_DATE
Name: Latest End Date Calc
Calculated Value: Min ([End Date MVF])
Type: DTYPE_DATE
You are ready! You can add a small code to read these Calc fields and populate the Parent BC fields Earliest Start Date and Latest End Date! (there might be a better way though)
Siebel is awesome :)
December 10, 2013
How to do "Generate Triggers" for new WF Policies to work?
"Generate Triggers", this is one of the step that one needs to perform whenever we create new WF Policies and make them work as per the conditions specified for the policy.
Here is the process to do that :
1. Navigate to "Administration - Server Management -> Jobs" view and click on New.
2. Put the Component/Job = "Generate Triggers"
3. Now, in the Job Parameters applet, you need to provide the following four parameters:
a) EXEC : TRUE
b) Remove : FALSE
c) Privileged User : "Database Table Owner Name"
d) Privileged User Password : "Table Owner Password"
4. Click on "Submit Job".
5. After few seconds, refresh the view (by clicking on "Execute Query" button), you will see Execution Server will get assigned to the request and Status changes to "Active".
6. After few minutes, again refresh the record and once the trigger gets generated, Status changes to "Success".
Here is the process to do that :
1. Navigate to "Administration - Server Management -> Jobs" view and click on New.
2. Put the Component/Job = "Generate Triggers"
3. Now, in the Job Parameters applet, you need to provide the following four parameters:
a) EXEC : TRUE
b) Remove : FALSE
c) Privileged User : "Database Table Owner Name"
d) Privileged User Password : "Table Owner Password"
4. Click on "Submit Job".
5. After few seconds, refresh the view (by clicking on "Execute Query" button), you will see Execution Server will get assigned to the request and Status changes to "Active".
6. After few minutes, again refresh the record and once the trigger gets generated, Status changes to "Success".
December 4, 2013
Shell script to bounce siebel server after incremental compile
Whenever you make changes to repository objects (SIFs) you will have to move the SRF to your dev environment.
The steps we follow are:
- Compile your objects on top of the latest SRF from server
- Stop Siebel Server
- Stop Gateway Name Server
- Move your new SRF
- Start Gateway Name Server
- Start Siebel Server
- Run genbsrcipt utility
Below is the shell script that helps you to do the above tasks in a single shell script. Save it as .sh (SIEBEL_STOP_MOVESRF_START.sh) file.
- CHANGE THE PATHS ACCORDINGLY
Here are the steps you need to follow:
1) Copy latest SRF from server(/siebsrvr/objects/enu) into your machine.
2) Compile your objects on top of that.
3) Place the compiled SRF in /u01/SRF folder. If you are using folder with different name make sure you update the variable "SRF_DIR" in the script. DO NOT MISS THIS!
4) Run SIEBEL_STOP_MOVESRF_START.sh
- Stops Siebel Server
- Stops Gateway Name Server
- Takes the backup of existing SRF (/u01/Siebel_8.2.2/siebsrvr/objects/enu) (Renames to siebel_sia_YYYY_MM_DD_hh_mm.srf)
- Copies latest SRF from "/u01/SRF" to "/u01/Siebel_8.2.2/siebsrvr/objects/enu"
- Starts Gateway Name Server
- Starts Siebel Server
- Runs genbsrcipt utility
- Deletes the SRF from SRF_DIR
#####################################################
#! /bin/bash
# CONSTANTS
ROOT="/u01"
//location where you place your compiled SRF
SRF_DIR="/u01/SRF"
//SRF directory
SBL_SRF_DIR="/u01/Siebel_8.2.2/siebsrvr/objects/enu"
//Siebel server
SBL_SRVR="/u01/Siebel_8.2.2/siebsrvr"
SBL_BIN="/u01/Siebel_8.2.2/siebsrvr/bin"
//Web server
SBL_WS="/u01/app/oracle/mwhome_1/Oracle_WT1/opmn/bin"
//Gateway server
SBL_GW="/u01/Siebel_8.2.2/gtwysrvr"
SBL_GW_BIN="/u01/Siebel_8.2.2/gtwysrvr/bin"
echo "Stopping Webserver"
cd $SBL_WS
./opmnctl stopall
echo "Setting up Siebel environment"
cd $SBL_SRVR
. ./siebenv.sh
echo "Stopping Siebel Server"
cd $SBL_BIN
stop_server all
echo "Setting up Gateway Name Server environment"
cd /u01/Siebel_8.2.2/gtwysrvr
cd $SBL_GW
. ./siebenv.sh
echo "Stopping Gateway Name Server"
cd /u01/Siebel_8.2.2/gtwysrvr/bin
cd $SBL_GW_BIN
stop_ns
echo "Killing additional Siebel processes"
pkill -9 -f Siebel
echo "Waiting for 60 Seconds for Siebel Server to shut down completely"
sleep 60
#### Set Date and Time Stamp into File Names ####
DATE_TIME=`date +%Y_%m_%d_%H_%M`
# Migration of SRF file
cd $ROOT
chmod 777 SRF
echo "Full permissions given to SRF folder"
cd $SBL_SRF_DIR
echo "Renaming old SRF file"
mv siebel_sia.srf siebel_sia_$DATE_TIME.srf
echo "Copying new SRF file"
cp $SRF_DIR/siebel_sia.srf $SBL_SRF_DIR/siebel_sia.srf
echo "Waiting for 10 Seconds before starting the services"
sleep 10
echo "Setting up Gateway Name Server environment"
cd /u01/Siebel_8.2.2/gtwysrvr
cd $SBL_GW
. siebenv.sh
echo "Starting Gateway Name Server"
cd /u01/Siebel_8.2.2/gtwysrvr/bin
cd $SBL_GW_BIN
start_ns
echo "Setting up Siebel environment"
cd /u01/Siebel_8.2.2/siebsrvr
cd $SBL_SRVR
. siebenv.sh
echo "Starting Siebel Server"
cd /u01/Siebel_8.2.2/siebsrvr/bin
cd $SBL_BIN
start_server all
echo "Generating browser scripts"
./genbscript "/u01/Siebel_8.2.2/siebsrvr/bin/enu/publicsector.cfg" /u01/Siebel_8.2.2/siebsrvr/webmaster
echo "Starting Webserver"
cd $SBL_WS
./opmnctl startall
echo "Removing SRF file from SRF_DIR"
cd $SRF_DIR
rm siebel_sia.srf
echo "Please wait for a few minutes for the Siebel server to startup"
#####################################################
Subscribe to:
Posts (Atom)