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".

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"

#####################################################

Batch Import of SIFs into Siebel Tools

As a developer you want/need to keep your local tools DB up to date but importing all those objects (SIFs) when there are too many modified objects is a time consuming task.
Normally all development projects will have version control tools like SVN, ClearCase etc. So you will have all changed objects in your local machine.
With the help of below code you can actually perform batch import with overwrite method

STEPS:
1) All you need to to is save the below content (from START to END) as a BAT file. and change the file paths accordingly.
2) Make sure you have closed your local tools before you run this BAT file.
3) Run the BAT file. Your tools instance will open up. Do not close it.
4) After the completion of import tools instance will automatically close.
5) Verify the log if required

===================================
:: START
:: To import SIFs to your local tools from a Folder
set root=D:
set siebeltoolsbin=D:\Siebel\8.2.2.0.0\Tools_1\BIN

::  your tools CFG path
set siebeltoolscfg=D:\Siebel\8.2.2.0.0\Tools_1\BIN\ENU\tools.cfg

:: object location (ex SVN path)
set siebelobjectspath=D:\Objects\Batch_Import

:: Log path
set logpath=D:\SIF_Import_log.txt

:: Datasource
set datasource=Local

:: Username and Password
set username=PDESAI
set pwd=PDESAI

ECHO Parameters set: Importing SIFs to Tools
%root%
CD %siebeltoolsbin%

::Importing the sif files
siebdev.exe /c %siebeltoolscfg% /d %datasource% /u %username% /p %pwd% /batchimport "Siebel Repository" Overwrite %siebelobjectspath% %logpath%

:: END

===================================

Using COMCreateObject to debug scripts

COMCreateObject is one of the better ways  to debug scripts. Here is an example.

function BusComp_PreSetFieldValue(FieldName, FieldValue)
{
    if (FieldName == "Selected APTC")
    {
        //Instantiate
        var WshShell = COMCreateObject("WScript.Shell");
        
        //to display a custom message
        WshShell.Popup("In BusComp_PreSetFieldValue",0,"Siebel");
        
        var sSelectedAPTC = this.GetFieldValue("Selected APTC");
        
        //to display a variable value
        WshShell.Popup(sSelectedAPTC,0,"Siebel");
        
        //to display custom message with variable value
        WshShell.Popup("sSelectedAPTC= "+sSelectedAPTC,0,"Siebel");
        
        //nullify
        WshShell = null;
    }
}

Sample Example:



Most Useful Calculated field Expressions

Below are the most commonly used expressions used in calculated fields. Hope it helps.

- Getting System Preference
IIf ([Is Agent]="Y", SystemPreference("AAA Assister ID Prefix") + Right(RowIdToRowIdNum([Id]),7), "")

- Calculate Age
(Today () - [Birth Date] )  / 365

- LOV Lookup
LookupName("AMS_LOV_APPLTYPE", [Applicant Type])
LookupValue('COMM_BOOLEAN_VALUE', IIf([COB Flg] ='N' or  [COB Flg] Is NULL,'No','Yes'))

- Getting Profile Attribute
GetProfileAttr("ApplicationName")

- Division example
[Assessment Value]/25
IIF([Hire Date] IS NOT NULL,(Today()-[Hire Date])/30,0)
[Equity Value] / [Book Value]

- Multiplication example
[Cost/Share] * [Shares Held]

- ToChar example
IIF([Fax Phone #] IS NOT NULL, '"/fax='+ToChar([Fax Phone #])+'/" <qatest50@qa.test.com>', "")

- Append example
[First Name] + " " + [Last Name]
"" + [Type] + ": " + [Description]
[First Name] + " " + [Middle Name] + " " + [Last Name]

- Getting Application Name
IIF(GetProfileAttr("ApplicationName") = "Siebel Public Sector", "N", [Protect Internal Employee Flag] )

- Getting Parent BC name
IIf (ParentBCName () = "LOY Member", ParentFieldValue ("Member Type"), "")

- Getting Parent BC Field name
IIf (ParentBCName () = "FINS cBanking Request", ParentFieldValue("Company Group Id"), "")
ParentFieldValue("Id") + "_" + [Id]

- Row Id to Number
RowIdToRowIdNum([Id])

- Simple IF example
IIF(IsManagerPosition(), 'N', 'Y')

- Date Time functions
Timestamp ()
IIF(Timestamp()>[Due] AND [Done] IS NULL, "Overdue", "Not Overdue")
Today ()

- Sum the values in MVF
Sum([Client Deposit Balance MVF])

- Count records in MVL
Count("Dealer Trade In")

- Calling business service from calculated field
InvokeServiceMethod ("AAA Calculate Enrolled Product CSR Level Service", "CalculateCSR", "PrimContactId="+[Primary Contact Id]+","+"PlanMedal="+[Plan Primary Coverage Level]+","+"ProductId="+[Product Id],"CSRLevel")

InvokeServiceMethod ("AAA Calculate Applied Premium Assistance Breakdown", "CalcBreakdown", "PID="+[Asset Id]+","+"TPA="+[PD Total Premium Assistance]+","+"PPA="+[Applied APTC],"SPAUsed")

- Link in calculated field
"<a href=# onClick=""window.open('http://10.10.10.79:8080/alfresco/d/d/workspace/SpacesStore/bffe76c5-3d18-4d9d-930a-50b9cd10e477/" + [App PDF Link] + "','_blank');return false;"">" + [App PDF Link] + "</a>"

- Other Examples
GetNumBCRows ("FINS Health Individual Policy", "FINS Member Benefits", '[Policy Coverage Id] ="'+[Id]+'"',"All")

GetNumBCRows ("HLS Case", "HLS Case", "[Status]= 'Closed'", "Sales Rep")

Max([PD Member End Dates])

IfNull([Graphical Policy Status Green], IfNull([Graphical Policy Status Yellow], IfNull([Graphical Policy Status Red], "Current Outage")))

Mid(Today(), 4, 2)

Left(Today(), 2)

Right(Today(), 2)

IfNull([Graphical Policy Status Green], IfNull([Graphical Policy Status Yellow], IfNull([Graphical Policy Status Red], "Current Outage")))

IfNull(Count ("Case QA Template"), 0)

IIf (LPDinId() <> [Created By],"Y","N")

(1.0 - [Cost]/IfNull([Promotional Price],[List Price]))*100.0

IIf (ParentBCName () = "Admin Price List" OR ParentBCName () = "Price List", ParentFieldValue ("Currency Code"), "")

ToChar([Service Length])+ " " +[Service Length UoM]

IIF(ParentFieldValue ("VerItm") LIKE "Inc*","Income", IIF(ParentFieldValue ("VerItm") LIKE "Exp*","Expense", IIF(ParentFieldValue ("VerItm") LIKE "Household C*","Household Composition", IIF(ParentFieldValue ("VerItm") LIKE "Res*","Resource" , "Field"))))

BCHasRows("FINS Health Individual Policy","FINS Member Benefits","[IHP Product Id]='" + [IHP Product Id] + "' AND [Insured Id]='" + [Insured Id] + "' AND ( [PD Policy Status] <> 'Terminated' AND [PD Policy Status] <> 'Lapsed')" ,"All")

LookupName("FINCORP_PROD_ADMIN_CLASS_MLOV", [Product Type])

IIf (([End Date] >= Timestamp()) AND ([Start Date] <= Timestamp()),Y,N)

IIF(ParentBCName() = "FINS Member Benefits", ParentFieldValue("IHP Product"), ParentFieldValue("Product Name"))

Left([Street Address],[Street Address Len])+ [Calculated Address Comma0.5] + [Street Address 2] + [Calculated Address Comma1]  + [City] + [Calculated Address Comma2] + [State]

Querying List Of Values BC in eScript

Many times we come across situations where in we need to perform query on List Of Values BC to get a value. What we usually do is by instantiating BO and BC then perform query.

There is a vanilla method for querying List of Values.

TheApplication.InvokeMethod("LookupValue", type, lang_inde_cd);
//it returns 'Value'

var LOV_Val=TheApplication().InvokeMethod("LookupValue","SR_SUBAREA","WASIN");

Calculate 18 years age Flag including leap years

Ways to calculate 18 years age Flag including leap years:

1. Create Calculated Field of todays date in YYYYMMDD Format:
e.g: Formatted Today Date : ToChar(Today(),'YYYY') + ToChar(Today(),'MM') + ToChar(Today(), 'DD')
            Field Type: DTYPE_NUMBER

2. Create another Calculated Field Birth date in YYYYMMDD Format:
e.g: Formatted Birth Date : ToChar([Birth Date], 'YYYY') + ToChar([Birth Date], 'MM') + ToChar([Birth Date], 'DD')
            Field Type: DTYPE_NUMBER

3. Set the Calculated Age Under 18 Flag as mentioned below:
            Age Under 18 Flg : IIf(([Formatted Today Date] - [Formatted Birth Date]) < "180000", "Y", "N")
            Field Type: DTYPE_TEXT

You are done!

ShowModalDialogue method in Browser Script

Lets say you are trying to open your facebook profile in a modal window. Below is the code to achieve it. Refer bookshelf for more details on ShowModalDialog.

function Applet_PreInvokeMethod (name, inputPropSet)
{
        if(name == "OpenProfile")
        {
                    var sProfileName = this.BusComp().GetFieldValue("Name");
                        var sURL = "https://www.facebook.com/"+sProfileName;
                   
                    var sOptions = "dialogHeight:400px;dialogWidth:600px;dialogTop:100px;edge:sunken;resizable;yes";
                    //alert(sURL);
                    theApplication().ShowModalDialog(sURL, "", sOptions);
                    return ("ContinueOperation");
        }
        return ("ContinueOperation");
}

Calling Business Service from browser script

//Version 8 and above
Add a Application User Property (in siebel tools) 
Name: ClientBusinessService9
Value: Your Business Service Name
Note: No need to make changes in client.cfg

//Version 7.x and below
locate [InfraUIFramework] section in your client CFG, add the BS entry as shown below
[InfraUIFramework]
ClientBusinessService[n]   = "Your Business Service Name"

//Invoking the BS from browser script
function Applet_PreInvokeMethod (name, inputPropSet)
{
        if(name == "OpenCOC")
        {
                    var psIn = theApplication().NewPropertySet();
                    var psOut = theApplication().NewPropertySet();
                    psIn.SetProperty("Type","URL");
                    var sService = theApplication().GetService("Your Business Service");
                    psOut = sService.InvokeMethod("GetURL", psIn);
                        //where as in server script the syntax will be
                        //sService.InvokeMethod("GetURL", psIn, psOut);
                        
                    var sCoCURL = psOut.GetProperty("URL");
                    return ("ContinueOperation");
        }
        return ("ContinueOperation");
}

Date Comparison: Compare a given date with Today() in eScript

function fnCompareCurrDate(dDate)
{
     try
     {
           var curdate = new Date();
           var curM = ToInteger(curdate.getMonth() + 1);
           var curD = ToInteger(curdate.getDate());
           var curY = ToInteger(curdate.getFullYear());
          
           var effdate = new Date(dDate);
           var effM = ToInteger(effdate.getMonth() + 1);
           var effD = ToInteger(effdate.getDate());
           var effY = ToInteger(effdate.getFullYear());


           if ((curY == effY) && (curM == effM) && (curD == effD))
           {
                return (1);
           }
           else
           {
                return (0);
           }
     }

     catch (e)
     {
           TheApplication().WriteOneGateLog("Error in function fnCompareCurrDate:", e.toString());
     }

}

Date Comparison: Compare two dates

 //Compare two dates
function fnCompareDates(dDate1, dDate2)
{
     var sDate1 = new Date(dDate1);
     var d1_M = ToInteger(sDate1.getMonth() + 1);
     var d1_D = ToInteger(sDate1.getDate());
     var d1_Y = ToInteger(sDate1.getFullYear());

     var sDate2 = new Date(dDate2);
     var d2_M = ToInteger(sDate2.getMonth() + 1);
     var d2_D = ToInteger(sDate2.getDate());
     var d2_Y = ToInteger(sDate2.getFullYear());

     if ((d1_Y < d2_Y) || ((d1_Y == d2_Y) && (d1_M < d2_M)) || ((d1_Y == d2_Y) && (d1_M == d2_M) && (d1_D < d2_D)))
     {
           return (1);
     }
     else
     {
           return (0);
     }

}

How to enable Siebel EAI logs?

Open your client CFG file
Add the following lines in your cfg file after [Siebel] Section
[EAISubsys]
EnableServiceArgTracing = TRUE
Save your CFG file


These dmp files will have the exact SOAP Request (OutboundDispatcher_output_args_xx.dmp) and SOAP Response returned by Web Service (OutboundDispatcher_input_args_xx.dmp). From now on if you even query using EAI Siebel Adapter business service you will see dmp files showing you exactly the input that was given to EAI Siebel Adapter BS and the output you received.

DBISQLC.EXE - Gateway to Siebel Local Database

What is DBISQLC.EXE?
DBISQLC.EXE is an Interactive SQL Anywhere program, located in the Siebel Tools or Siebel Web Client folder, and is used to connect to sample/local database for DML, DDL operations.

Where can I find DBISQLC.EXE?
It can be found in BIN folder of Siebel Tools or Siebel Web Client. For ex, D:\Siebel\8.2.2.0.0\Client_1\BIN\dbisqlc.exe

How Do I run a query?
1. In the Command sub-window, type the query you want to perform. Make sure that you put the table owner name in front of the Siebel table names (i.e. SIEBEL.S_CONTACT instead of just S_CONTACT).
SELECT FST_NAME, LAST_NAME FROM SIEBEL.S_CONTACT;

2. Click on the Execute button (F9) to run the query.

How do I export the results of the SQL:
We can do this by using OUTPUT TO command.
You can export the results to a TXT file. Below is an example,
SELECT FST_NAME, LAST_NAME FROM SIEBEL.S_CONTACT;
OUTPUT TO C:\OUTPUT.TXT
FORMAT ASCII


You can export the results to a CSV file. Below is an example,
SELECT FST_NAME, LAST_NAME FROM SIEBEL.S_CONTACT;
OUTPUT TO C:\OUTPUT.CSV
FORMAT ASCII