Friday, September 9, 2011

Restricting Duplication of record by Validation using Configuration:

Description:

Validating a record existance by  checking the combination of some defined fields, pops an error message if the record already exists with that field values.

Requirement:

An attempt to create a new ‘Contact’  should fail  if the provided values for ‘First Name’ and ‘Last Name’ for Contact  are same as that of any existing record. An error message should pop  up while trying to save such a record.

Configuration Steps:

1.       Create a New calculated field in Contact BC, where the calculated value contains the functionality with below search criteria.
Name: Test_Duplicate
Calculated: True
Calculated Value: 
BCHasRows("Contact", "Contact","[First Name] = '"+[First Name]+ "'" +  "AND" + "[Last Name] = '"+[Last Name]+"'" , "All")

BCHasRows function  is specified with 4 parameters like
BCHasRows( “BO”,” BC”, “Searchspec”, “Visibility” ).


The calculated value for Test_Duplicate is returned as ‘Y’ if the search specification is satisfied, else it returns ‘N’.

2.       Add the validation criteria and validation message to one of the  search criteria fields(Either First Name or Last Name) or the required fields of the BC, so that validation is checked before the record gets saved.
a.         Query for Last Name field in Contact BC.
b.        Update the record with the following values:
Validation : [Test_Duplicate] <> "Y"
Validation Message: Record Exists

If the Validation is satisfied, i.e. if the value for the Test_Duplicate field  is ‘N’ , the new record gets saved because the combination of the values entered for First Name and Last Name doesn’t match with any of existing records.

If the Validation is not satisfied, i.e. if the value for the Test_Duplicate field is ‘Y’ , error message “Record exists”  is popped up and the record will not get saved, until you give new values to ‘First Name’ and ‘Last Name’.


 

SBL-DAT-00215: This operation is not allowed when there are no records displayed. Please execute a query that returns at least one record or add a new record.

We mostly come acoss this error during application development.Below are few explanations and Corrective actions provided by Oracle.

Explanation


1. A particular operation, usually an update, has failed because there are no records available in the current query. Either the query needs to be changed to ensure it returns records, or the operation should be prevented if the query does not return records. The operation and its preceding query may have been initiated through any of the following: user actions directly in the UI, Enterprise Integration Manager (EIM), eBusiness Application Integration (EAI), business services or other scripting, workflow processes, object interfaces such as COM or CORBA, or Data Quality activities.

2. A query may be returning no records due to incorrect configuration in Siebel Tools objects, workflow process, scripting, or a business service.

3. If the operation is triggered by an automated action such as a script, there should be a check to ensure there are records in the current query and prevent the operation if no records are present.

4. If the error occurs on a copied buscomp or applet which uses a special class, there may be specialized functionality which does not work properly on the copied object. For example, there may be user properties referencing the original buscomp name.

5. The error may occur when importing workflow processes, due to one or both of the following:
(a) An issue with the Front Office Workflow definition in Siebel Tools
(b) Multiple exception connectors have been defined with the same name

6. The error may occur when updating baseline data in Sales Volume Planning if the Populate Locks action has not been run on the Sales Volume Planning Administration view.

Corrective Action



1. Use SQL logging to identify the query run and operation attempted. The SQL logging method will differ depending upon which action is triggering this error. If possible, use additional logging to determine the buscomp upon which the query and attempted operation were run.

2. In Siebel Tools, look up the buscomp against which the query ran. Check the search specification and view mode properties on the buscomp, applet, and view. If any joins are defined on the buscomp, make sure the Outer Join Flag is appropriately set. If the query was run by a script, make sure you have used SetViewMode and SetSearchSpec or SetSearchExpr appropriately. If the query is run using a Siebel Operation in a workflow process, check the search specification defined in the Workflow Process Designer.

3. If the query and operation are performed from a custom script or business service, make sure there is validation in the script to ensure that records were returned by the query before attempting the operation.

4. If the error occurs on a copied object using a special class, check for special user properties such as On Field Update Invoke which may be automatically trying to invoke a specialized method. Avoid copying specialized objects, as noted in Siebel Bookshelf version 7.7 > Configuring Siebel eBusiness Applications > Overview of Configuring Siebel Applications > About Configuring Siebel Applications > About Copying Objects.

5. If the error occurs when importing workflow processes:
(a) Follow the steps documented in Alert 594 on SupportWeb.
(b) Check the workflow processes you are attempting to import to ensure they do not have multiple exception connectors defined with the same name.

6. If the error occurs when updating baseline data in Sales Volume Planning, review FAQ 2071 on SupportWeb and ensure that the Populate Locks action has been run.

Saturday, August 27, 2011

Script to Calculate Commit time

function Commit_Time_Value(responseTime)
{
                                                       
    //***************************************************************************                           
    //Created        Created By        Description           
    //           This script checks the value of the " Service Level Response Time"               
    //                            and sets the value of the "Commit Time" field.
    //************************************************************************                           
    try                           
      {                           
        var lsTimeInDays = "" ;                       
        var lsTimeInHours = "" ;                       
        var lsCreatedTime ;                       
        var lsCommitTime ;                       
   
        lsCreatedTime = new Date(this.GetFieldValue("Created"));                       
            switch(responseTime)                   
            {                   
                //Store the time in days or hours.               
                case "1 Day":               
                    lsTimeInDays = "1" ;           
                    break ;           
                case "2 Days":               
                    lsTimeInDays = "2" ;           
                    break ;           
                case "3 Days":               
                    lsTimeInDays = "3" ;           
                    break ;           
                case "4 Days":               
                    lsTimeInDays = "4" ;           
                    break ;           
                case "5 Days":               
                    lsTimeInDays = "5" ;           
                    break ;           
               case "6 Days"://IR 7.3 added                       
                    lsTimeInDays = "6" ;           
                    break ;           
                case "10 Days":               
                    lsTimeInDays = "10" ;         
                    break ;           
                case "7 Days":               
                    lsTimeInDays = "7" ;
                    break ;           
                case "N/A (not applicable)":               
                    lsTimeInDays = "" ;
                    break ;           
                case "4 Hours":               
                    lsTimeInHours = "4" ;           
                    break ;           
                case "6 Hours":               
                    lsTimeInHours = "6" ;           
                    break ;           
                default:               
                    break ;//Do nothing           
            }                   
            if(lsTimeInDays != "")                   
            {                   
                //Increment time by No. of days * hours in a day * minutes in hour * seconds in min * milli secs in sec   
                lsCommitTime = CalculateCommit_Time_Excl_Wkds (lsCreatedTime, lsTimeInDays);       
                //lsCommitTime = new Date(lsCreatedTime.getTime() + lsTimeInDays*24*60*60*1000) ;                               
                this.SetFieldValue("Commit Time",DateToString(lsCommitTime)) ;               
            }                   
            else                   
            {                   
                if(lsTimeInHours != "")               
                {               
                    //Increment time by No. of hours * minutes in hour * seconds in min * milli secs in sec           
                    lsCommitTime = new Date(lsCreatedTime.getTime() + lsTimeInHours*60*60*1000) ;           
                    this.SetFieldValue("Commit Time",DateToString(lsCommitTime)) ;           
                }               
            }                   
      }                           
    catch(e)                           
    {                           
        //Handle errors                       
        var ls_error_text;                       
        var le_new_exception;                       
        ls_error_text = e.toString();                       
        ls_error_text += " Error in Commit_Time_Value Method of ATC Service Request BC.";                       
        le_new_exception = ToObject(ls_error_text);                       
        throw le_new_exception;                       
    }                           
    finally                           
    {                           
        //Destroy objects                       
    //    responseTime = null;                       
        lsCommitTime = null ;                       
        lsCreatedTime = null ;                       
        lsTimeInHours = null ;                       
        lsTimeInDays = null ;                       
    }                           
                               
}

function CalculateCommit_Time_Excl_Wkds (SRCreatedDate,days)
{

      //SRCreateDate = starting date, days = no. working days to add.
                  var i = 0;
                  var days_to_add = 0;
                  var dtCreatedDate = new Date();
                  while (i < (days))
                  {
                          dtCreatedDate = new Date(SRCreatedDate.getTime() + (days_to_add*24*60*60*1000));
                        //0 = Sunday, 6 = Saturday, if the date notequals a weekend day then increase by 1
                        if ((dtCreatedDate.getDay() != 5) &&(dtCreatedDate.getDay() != 6))
                        {
                              i = i + 1;
                        }
                        days_to_add = days_to_add + 1;

                  }

                  return new Date(SRCreatedDate.getTime() +days_to_add*24*60*60*1000);


}

Script to Convert Date to String

//***************************************************************************                           
    //Created        Created By  Minaresh     
     Description      : This script Converts the inputs date to String .
    //************************************************************************        

function DateToString (cDate)
{
var sDatum = ((cDate.getMonth() + 1) + "/" + cDate.getDate() + "/" + cDate.getFullYear()
+ " " + cDate.getHours() + ":" + cDate.getMinutes()+ ":" + cDate.getSeconds());
return sDatum
}

Friday, August 26, 2011

When a New Service Request is Created SR should be automatically assigned to Defalt queue Owner

Below code needs to be written in New Record Event.

function BusComp_NewRecord ()
{
    var srOwner = TheApplication().InvokeMethod("LookupValue","ATC_QUEUE_ASSIGNMENT", "Default Queue");
    this.ActivateField("Owner");
    var srOwnerPickList = this.GetPicklistBusComp("Owner");
    srOwnerPickList.SetViewMode(AllView);
    srOwnerPickList.ActivateField("Login Name");
    srOwnerPickList.ClearToQuery();
    srOwnerPickList.SetSearchSpec("Login Name", srOwner);
    srOwnerPickList.ExecuteQuery(ForwardOnly);       
    if (srOwnerPickList.FirstRecord())
        srOwnerPickList.Pick();
    srOwnerPickList = null;
    isNewCIRSR = "Y";
}

Saturday, June 18, 2011

What is diffrence between Profile Attributes and SharedGlobal:

Both are basically used for storing values which can be accessed from anywhere in the Application. Both are user and session specific.

a) Profile Attributes comes with Siebel Personalization. If EnablePersonalization = False in the CFG, Profile Attributes will not work. There are two types of Profile Attributes:

1) Persistent Profile Attributes
2) Dynamic Profile Attributes

Persistent Profile Attributes are mapped to the fields in the Business Component "Personalization Profile". Dynamic Profile Attributes are created at run time and are not based on any Business Component fields.

Dynamic profile attributes is generally what we use most of the time.

b) GlobalShared can not be used in browser scripts. Profile Attributes can be used in browser scripts.
c) Profile Attributes are supported in Calculated Values, Search Specifications etc but GlobalShared is not.
d) Profile Attributes are mainly used in Personlization Rules to control the Applet and View visibility 

Scripting Paths for return (CancelOperation) in browser or server script:

If you are curious about how CancelOperation works in browser and server scripts below information will make you understand better.

return (CancelOperation) in Applet PreInvoke Method Browser Script

Applet_PreInvoke -> End

return (CancelOperation) in Applet PreInvoke Method Server Script
Applet_PreInvoke -> WebApplet_PreInvoke -> Applet_Invoke -> End

return (CancelOperation) in BusComp PreInvoke Method Server Script
Applet_PreInvoke -> WebApplet_PreInvoke -> BusComp_PreInvoke -> WebApplet_Invoke -> Applet_Invoke -> End


return (CancelOperation) in BusComp Invoke Method Server Script
No Impact

return (CancelOperation) in Applet Invoke Method Server Script
No Impact

return (CancelOperation) in Applet Invoke Method Browser Script
No Impact


return (CancelOperation) on post events does not do anything. For example, if you write return (CancelOperation) in
Applet_InvokeMethod, Buscomp_InvokeMethod, BusComp_NewRecord etc, it does not make any difference to the scripting
flow.

return (CancelOperation) plays role only on Pre events like PreInvokeMethod, PreNewRecord, PreWriteRecord etc

Tuesday, January 11, 2011

How to set the environment variable ??

Right Click on My Computer --> Properties--> Advanced -->Environment Variables--> Add and set the value of the new environment variables: SIEBEL_LOG_EVENTS = 4 and SIEBEL_FACAP_LOG_EVENTS = 5

How to improve performance of Siebel Tool/Client/Hangs ???

1.Always Close siebel tool/client from file->Exit, Because improper close of siebel tool, Kept log of all transaction and don't delete all after tool close. When you close tool from file->Exit, it removes/ deletes all transaction log saved in S_DOCK_TXN_LOG
2.Truncate table S_DOCK_TXN_LOG .It will delete all transaction log that has not been deleted automatically because of improper exit of siebel tool.
S_DOCK_TXN_LOG : Keep tracks of all DB changes(field level) through application.

3.Make AutoStopDB = TRUE in tool.cfg and client.cfg
4.Don't remove server name from odbc,that is readyment server.
5.Remove additional parameter of local ConnectString
ConnectString = C:\PROGRA~1\Siebel\8.0\Tools\LOCAL\sse_data.dbf -q -m -x NONE
6.In ODBC, Supply user id and password of SIEBEL