Bookshelf Home | Contents | Index | PDF | ![]() ![]() |
Siebel Object Interfaces Reference > Using Siebel Visual Basic and Siebel eScript > Configuring Error Handling > Guidelines for Using Siebel VB and Siebel eScriptThis topic describes guidelines for using Siebel VB and Siebel eScript. It includes the following topics:
For introductory information about Siebel VB, see Siebel VB Language Reference. Declare Your VariablesTo help other developers understand your code and to help you debug your code, it is recommended that you declare your variables. Declaring Your Variables in Siebel VBYou can use the Dim statement in the Option Explicit statement to declare a variable before you use it. To reduce the amount of memory that your code uses and to improve processing speed, it is recommended that you avoid using a Variant variable. You can declare a variable without specifying a data type. If you do not specify a data type, then Siebel VB assumes the Variant type. This type requires 16 bytes and uses twice as much memory as the next smallest data type. Use a Standardized Naming ConventionTo improve efficiency and reduce errors, it is recommended that all developers in your programming group use the same standardized naming convention. The convention that you use does not matter. Table 6 describes a common convention that prefixes each variable with a letter that indicates the type. If necessary, you can also use a suffix.
Use Constants to Standardize CodeSiebel Visual Basic and Siebel eScript provide constants that you can use to make your code more readable by other developers. A constant clarifies the intent of the operation. Use the constant name in your code. Do not use the integer value in your code. The integer value is included only to aid in debugging. If you store the constant in a local variable, and if the value of the local variable is available, then Siebel CRM displays the integer value in the Debugger. Table 7 lists the Siebel constants you can use. It is recommended that you use the constant and that you do not use the integer value because integer values are subject to modification.
Avoid Nested If StatementsTo avoid a nested If statement, you can use one of the following statements: Each of these statements chooses from multiple alternatives according to the value of a single variable. It is recommended that you use the Select Case statement instead of a series of nested If statements. It simplifies code maintenance and improves performance. Siebel CRM evaluates the variable only once. The following is an example use of the Switch statement: switch (FieldName) Applying Multiple Object Interface Methods to a Single ObjectTo apply multiple object interface methods to a single object, you can use the With statement in Siebel VB or Siebel eScript. It reduces typing and makes the code easier to read. Example of Using the With Statement in Siebel VBThe following example uses the With statement in Siebel VB: Set oBusObject = TheApplication.GetBusObject("Opportunity") Set oBusComp = Nothing The following example is not recommended. It does not use the With statement: Set oBusObject = TheApplication.GetBusObject("Opportunity") Example of Using the With Statement in Siebel eScriptThe following example uses the With statement in Siebel eScript: var oBusObject = TheApplication().GetBusObject("Opportunity"); The following example is not recommended. It does not use the With statement: var oBusObject = TheApplication().GetBusObject("Opportunity"); Use a Self-Reference to Indicate the Current ObjectTo indicate the current object, you can use the following statements: You can use the statement or keyword instead of referencing an active business object. Example of Using the Me StatementThe following business component event handler uses the Me statement instead of the ActiveBusComp statement: Function BusComp_PreSetFieldValue(FieldName As String, FieldValue As String) As Integer For examples of using the Me statement, see the following topics:
Example of Using the This KeywordThe following business component event handler uses the This keyword instead of the ActiveBusComp statement: if (condition) Delete Objects You Have Created That You No Longer RequireAlthough the interpreter performs object cleanup, it is recommend that you write code that explicitly deletes objects it created that you no longer require. Your code must delete each Siebel object in the same procedure it used to create it. To delete objects, do the following: You can delete these objects in the reverse order that the code created them. Make sure you code deletes child objects before it deletes parent objects. Example of Deleting Objects in Siebel VBThe following code is an example of deleting objects in Siebel VB: Set oBusObj = TheApplication.GetBusObject("Contact") Example of Deleting Objects in Siebel eScriptThe following code is an example of deleting objects in Siebel eScript: var oBusObject = TheApplication().GetBusObject("Contact""); Make Sure Function Names Are UniqueMake sure that the name is unique for every function you create. If two functions use the same name, and if those functions are in the same view, then results are unpredictable. Consider using a naming convention, such as using the view name as a function name prefix. Manage the Script BufferThe size limit of a non-Unicode script buffer is 65530 bytes. The amount of available memory limits the Unicode script buffer. Make sure your computer possesses enough memory to accommodate this buffer. Using Siebel VB and Siebel eScript FormatsThere are some important differences between the formats that Siebel VB and Siebel eScript use:
In many instances, the only difference between the Siebel VB format and the Siebel eScript format is that the Siebel eScript format requires a pair of parentheses at the end. In these instances, this book only includes the Siebel VB format. To determine the Siebel eScript format, add the parentheses. Differences Between Siebel eScript and ECMAscriptECMAscript is a programming language that developers use to script a client on the Web. JavaScript is a type of ECMAscript. Siebel eScript does not include user interface functions. You cannot use it to animate or control a Web page. It includes the following functions that are not part of ECMAscript: You can use these functions to interact with the operating and file systems, and for performing input and output file operations. These objects include functions that are similar to functions that the C programming language uses. For more information, see Siebel eScript Language Reference. ECMAscript does not require you to declare a variable. It declares a variable implicitly as soon as you use it. Handling the Date Format in Siebel VBIf you use an object interface method that includes a date, then use caution regarding the date format. The GetFieldValue method returns the date in the following format: The CVDate function expects the regional setting. If you apply it, then Siebel CRM might return an error. The GetFormattedFieldValue method uses the regional settings of the operating system that is installed on the computer that runs the Siebel client. The regional setting might specify the year with two digits, and can cause an error with the year 2000 problem. For these reasons, use the following procedure for performing date arithmetic. To handle the date format in Siebel VB
Returning Run-Time Errors in Siebel VBThis topic describes how to return run-time errors in Siebel VB. To return run-time errors in Siebel VB
The GetLastErrText method is only available if you use an interface that is external to Siebel Tools. You can use it in Microsoft VB but not in Siebel VB. Object interface methods use numeric error codes in a range of 4000 to 4999. For more information about error-handling and error codes, see Siebel VB Language Reference. |
![]() ![]() |
Siebel Object Interfaces Reference | Copyright © 2018, Oracle and/or its affiliates. All rights reserved. Legal Notices. | |