0% found this document useful (0 votes)
149 views

Examples Escript

This document provides examples of server-side and browser-side scripting events in Siebel applications. It includes examples of scripting events for applets, applications, business components, business services, and a custom business service called "Shipping Engine" that calculates shipping costs. The examples demonstrate how to handle various events like loading, invoking methods, changing fields, and writing records to perform validation and customize behavior.

Uploaded by

venkat576
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
149 views

Examples Escript

This document provides examples of server-side and browser-side scripting events in Siebel applications. It includes examples of scripting events for applets, applications, business components, business services, and a custom business service called "Shipping Engine" that calculates shipping costs. The examples demonstrate how to handle various events like loading, invoking methods, changing fields, and writing records to perform validation and customize behavior.

Uploaded by

venkat576
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
You are on page 1/ 25

Examples

SERVER SIDE SCRIPTS &


BROWSER SIDE SCRIPTING
Applet Level Scripts
• Applet Events
• Applet_ChangeFieldValue Event
• Applet_ChangeRecord Event
• Applet_InvokeMethod Event
• Applet_Load Event
• Applet_PreInvokeMethod Event
• WebApplet_InvokeMethod Event
• WebApplet_Load Event
• WebApplet_PreCanInvokeMethod Event
• WebApplet_PreInvokeMethod Event
• WebApplet_ShowControl Event
• WebApplet_ShowListColumn Event
Browser Script
Applet ChangeFieldValue(Field,Value)
• function Applet_ChangeFieldValue (field, value)
{
   try
   {
      switch (field)
      {
         case "Primary Revenue Committed Flag":
         if (value == "Y")
         {
            var thisBC = this.BusComp();
            var sRev = thisBC.GetFieldValue("Primary Revenue Amount");
            var sUpside = thisBC.GetFieldValue("Primary Revenue Upside Amount");
            var total = sRev + sUpside;
            if (total < 500000)
            {
               thisBC.SetFieldValue("Primary Revenue Committed Flag", "N");
               alert("Changing the Committed Flag to NO as $500,000 in Revenue + Upside
amount is required");
            }
         }
         break;
      }
   }
   catch(e)
   {
      alert("Error in ChangeFieldValue and error is " + e.toString() + " " + e.errText());
   }
}
Applet_ChangeRecord
• The ChangeRecord event is called when the user moves to a
different row or view.

• function Applet_ChangeRecord ()
{
   try
   {
      var thisBC = this.BusComp();
      var sFlag = thisBC.GetFieldValue("Primary Revenue Committed
Flag");
      if (sFlag == "Y")
      {
         alert("This record cannot be update as its been Committed");
      }
   }
   catch(e)
   {
      alert("Error in ChangeFieldValue and error is " + e.toString() + " "
+ e.errText());
   }
}
The PreInvokeMethod event is called before a specialized method
is invoked, by a user-defined applet menu, or by calling
InvokeMethod on an applet.

• function Applet_PreInvokeMethod (name, inputPropSet)


{
   if(name == 'NewRecord')
   {
      if(confirm("Are you sure you want to create a new
record?"))
         return ("ContinueOperation");
      else
         return ("CancelOperation");
      return ("ContinueOperation");
   }
}
Application Events
• Application Events
• Application_Close Event
• Application_InvokeMethod Event
• Application_Navigate Event
• Application_PreInvokeMethod Event
• Application_PreNavigate Event
• Application_Start Event
• The PreInvokeMethod event is called before a specialized method is
invoked by a user-defined applet menu or by calling InvokeMethod
on the application.

• function Application_PreInvokeMethod (MethodName)


•    var iReturn = ContinueOperation;
   
   switch (MethodName)
   {
      case "LaunchWord":
         Clib.system("\"C:\\Program Files\\Microsoft Office
\\Office\\WINWORD.EXE"",1);
         iReturn = CancelOperation;
         break;
•       case "LaunchExcel":
         Clib.system("\"C:\\Program Files\\Microsoft Office
\\Office\\EXCEL.EXE"",1);
         iReturn = CancelOperation;
   }
   
   return (iReturn)
}
Business Component
• Business Component Events
• BusComp_Associate Event
• BusComp_ChangeRecord Event
• BusComp_CopyRecord Event
• BusComp_DeleteRecord Event
• BusComp_InvokeMethod Event
• BusComp_NewRecord Event
• BusComp_PreAssociate Event
• BusComp_PreCopyRecord Event
• BusComp_PreDeleteRecord Event
• BusComp_PreGetFieldValue Event
• BusComp_PreInvokeMethod Event
• BusComp_PreNewRecord Event
• BusComp_PreQuery Event
• BusComp_PreSetFieldValue Event
• BusComp_PreWriteRecord Event
• BusComp_Query Event
• BusComp_SetFieldValue Event
• BusComp_WriteRecord Event
• The PreSetFieldValue event is called before a value is pushed down
into the business component from the user interface or through a
call to SetFieldValue.

• function BusComp_PreSetFieldValue (FieldName, FieldValue)


{
   var msgtext = "Discounts greater than 20% must be approved";
   if (FieldName == "Discount")
   {
      if (FieldValue > 20)
      {
         TheApplication().RaiseErrorText(msgtext);
         return (CancelOperation);
      }
      else
      {
         return (ContinueOperation);
      }
   }
   else
   {
      return (ContinueOperation);
   }
}
• The PreWriteRecord event is called before a row is
written out to the database. The event may perform any
final validation necessary before the actual save occurs.

• Function BusComp_PreWriteRecord As Integer


•    ' This code resets the probability before the write
   ' if necessary
•    if Me.GetFieldValue("Sales Stage") LIKE "07*" then
      ' Resets the Probability to 75 if less than 75
      if Val(Me.GetFieldValue("Rep %")) < 75 then
         Me.SetFieldValue "Rep %", "75"
      end If
   end if
   BusComp_PreWriteRecord = ContinueOperation
End Function
The SetFieldValue event is called when a value is
pushed down into the business component from the user
interface

• function BusComp_SetFieldValue
(FieldName)
{
   if (FieldName == "Type" &&
GetFieldValue(FieldName) == "Account")
   {
      SetFieldValue("Description", "Record
is of Type 'Account'." );
   }
}
Business service
• Business Service Events
• Service_InvokeMethod Event
• Service_PreCanInvokeMethod Event
• Service_PreInvokeMethod Event
• This Browser Script example invokes
the Shipping Engine business service
created in Service_PreInvokeMethod
Event in response to a button click.
The InvokeMethod property on the
Button is set to "CalcShipping". It gets
values from the keyboard through
prompts (JavaScript method), passes
a property set to the service, and gets
return values by means of another
property set.
• function Applet_PreInvokeMethod (name,
inputPropSet)
• {
   if (name == "CalcShipping") {
      var svc = theApplication().GetService("Shipping
Engine");
      var inputs = theApplication().NewPropertySet();
      var outputs = theApplication().NewPropertySet();
•       var size = prompt("Enter the sum of H+W+D in
inches");
      var shipper = prompt("Enter the shipping
company");
      var weight = prompt("Enter the shipping weight in
pounds");
•       with (inputs) {
         SetProperty ("Size", size);
         SetProperty ("Shipping Company", shipper);
         SetProperty ("Ship Method", shipMethod);
         SetProperty ("Weight", weight);
         }
•       outputs = svc.InvokeMethod("CalculateShipping",
inputs);
      var cost = outputs.GetProperty("Cost");
      var delDate = outputs.GetProperty("Delivery Date");
•       TheApplication().SWEAlert ("Shipping by " + shipper +
":\n Shipping Cost is " +
            cost + ",\n Estimated delivery date is " +
            delDate);
•       return (CancelOperation);
•    }
•    else
•       return (ContinueOperation);
• }
• This Siebel VB example creates the new service
"Shipping Engine."
• Function Service_PreInvokeMethod (MethodName As
String, Inputs As PropertySet, Outputs As PropertySet)
As Integer
•    If MethodName = "CalculateShipping" Then
•       Dim sShipper As String, sShipMethod As String
      Dim dWeight As Double, dSize As Double, dCost As
Double
      Dim sZone As String, DelDate As Variant
      Dim sCost As String, iReturn As Integer
•       iReturn = ContinueOperation
      sShipper = Inputs.GetProperty("Shipping Company")
      sShipMethod = Inputs.GetProperty("Ship Method")
      dWeight = Val(Inputs.GetProperty("Weight"))
      dSize = Val(Inputs.GetProperty("Total Dimensions"))
      iZone = Val(Inputs.GetProperty("Zone"))
      DelDate = DateValue(Now)
•       Select Case sShipper
         Case "GlobalEx"
            Select Case sShipMethod
               Case "Next-Day Air"
                  dCost = 14 + dWeight
                  DelDate = DelDate + 1
               Case "Second-Day Air"
                  dCost = 11 + (dWeight * .54)
                  DelDate = DelDate + 2
            End Select
•          Case "Airline"
            Select Case sShipMethod
               Case "Next-Day Air"
                  dCost = 5 + (dWeight * .3) + (dSize * .33) + _
                     (Val(sZone) * .5)
                  DelDate = DelDate + 1
               Case "Second-Day Air"
                   dCost = 4 + (dWeight * .3) + (dSize * .2) + _
                     (Val(sZone) * .3)
                  DelDate = DelDate + 2      
•              
•   Case "Ground"
                  dCost = 3 + (dWeight * .18) + (dSize * .1) + _
                     (Val(sZone) * .1)
                  DelDate = DelDate + 2 + Int(Val(sZone) * .8)
            End Select
      End Select
•       sCost = Format(dCost, "Currency")
      Outputs.SetProperty "Cost", sCost
      Outputs.SetProperty "Delivery Date", DelDate
      iReturn = CancelOperation
•    End If
•    Service_PreInvokeMethod = iReturn
• End Function
• This Siebel VB example creates the new service "Shipping Engine."
• Function Service_PreInvokeMethod (MethodName As String, Inputs As PropertySet, Outputs As PropertySet) As Integer
•    If MethodName = "CalculateShipping" Then
•       Dim sShipper As String, sShipMethod As String
      Dim dWeight As Double, dSize As Double, dCost As Double
      Dim sZone As String, DelDate As Variant
      Dim sCost As String, iReturn As Integer
•       iReturn = ContinueOperation
      sShipper = Inputs.GetProperty("Shipping Company")
      sShipMethod = Inputs.GetProperty("Ship Method")
      dWeight = Val(Inputs.GetProperty("Weight"))
      dSize = Val(Inputs.GetProperty("Total Dimensions"))
      iZone = Val(Inputs.GetProperty("Zone"))
      DelDate = DateValue(Now)       Select Case sShipper
         Case "GlobalEx"
            Select Case sShipMethod
               Case "Next-Day Air"
                  dCost = 14 + dWeight
                  DelDate = DelDate + 1
               Case "Second-Day Air"
                  dCost = 11 + (dWeight * .54)
                  DelDate = DelDate + 2
            End Select
•          Case "Airline"
            Select Case sShipMethod
               Case "Next-Day Air"
                  dCost = 5 + (dWeight * .3) + (dSize * .33) + _
                     (Val(sZone) * .5)
                  DelDate = DelDate + 1
               Case "Second-Day Air"
                   dCost = 4 + (dWeight * .3) + (dSize * .2) + _
                     (Val(sZone) * .3)
                  DelDate = DelDate + 2      
•                Case "Ground"
                  dCost = 3 + (dWeight * .18) + (dSize * .1) + _
                     (Val(sZone) * .1)
                  DelDate = DelDate + 2 + Int(Val(sZone) * .8)
            End Select
      End Select
•       sCost = Format(dCost, "Currency")
      Outputs.SetProperty "Cost", sCost
      Outputs.SetProperty "Delivery Date", DelDate
      iReturn = CancelOperation
•    End If
•    Service_PreInvokeMethod = iReturn
• End Function
• The PreCanInvokeMethod event is called
before the PreInvokeMethod, allowing the
developer to determine whether or not the
user has the authority to invoke the
business service method. The
Advanced Example & Workflow
• Within a workflow process, you can store a
property set in a process property of type
Hierarchy. To pass the content of a
process property to or from a custom
business service, however, the Type of the
child property set stored in the process
property must match the name of the input
or output argument of the business
service.

You might also like