Вы находитесь на странице: 1из 6

Technical Note 198: Accessing File Attachments Through Siebel VB, Siebel eScript, and Siebel Object Interfaces

Last Modified: Area(s): Release(s): 23 August 2004 Siebel VB/eScript/Browser Script/COM V5 (Siebel 99-Enterprise), V6 (Siebel 2000-Enterprise), Version 4, V7 (Enterprise), V5 (Siebel 99-MidMarket), V6 (Siebel 2000MidMarket), V7 (MidMarket) All Supported Databases All Supported Platforms V7 (Enterprise) File attachment, access, method, Siebel VB, Siebel BusObject Interfaces

Database(s): App Server OS(s): Latest release tested against: Keywords:

Background In Siebel applications, external files are stored in the Siebel file system. These files are compressed and stored using a specialized naming convention. Connected users have direct access to the Siebel file system. Mobile users have a local file system in the Siebel client installation directory. Copies of files retrieved from the Siebel file system during synchronization are stored in the local system for access while the client is offline. These files are accessible and readable by the Siebel client. Siebel 7 uses the File System Manager for file attachments, therefore the file attaching operation is different from previous releases of Siebel applications. For the Siebel Web Client, the web browser will get the file from the users machine and send it to the Siebel Web Server. The Siebel Web Server Extension will then send the file to a temp folder that can be accessed by the Siebel Server component. The Siebel Server then compresses the file and adds it to the Siebel File System. For more information on the File System Manager functionality, refer to Siebel Bookshelf version 7.7 > Siebel System Administration Guide > Siebel Server Infrastructure Administration > Administering the Siebel File System > About the Siebel File System. Files in the Siebel file system can be manipulated programmatically using three invokable methods. This technical note documents the syntax and usage of these methods. The supported methods are: CreateFile GetFile PutFile

These methods are available for all business components whose Class = CSSBCFile. In Siebel 7, the methods can be accessed from server script using Siebel VB or Siebel eScript, the COM Data Control, Java Data Bean, or the Mobile/Dedicated Web Client Automation Server. These methods cannot be accessed from browser script. In Siebel 2000 and earlier, they can be accessed from Siebel VB, Siebel eScript, Siebel COM Automation Server, or the Siebel COM Data Server. The Siebel COM Automation Server and Siebel COM Data Server were known as the Siebel OLE Automation Server and Siebel OLE Data Server in Siebel 98.

page 1 of 6

Technical Note 198: Accessing File Attachments Through Siebel VB, Siebel eScript, and Siebel Object Interfaces

In Siebel 7, these file attachment methods only mimic the last step of file attachment processing, which is compressing the file and putting it into the Siebel File System. There is no script mechanism that can handle the file transfer between the client and server. Therefore, if you are creating a new file attachment or updating an existing file attachment, you have to store the file in a location which is accessible to the Siebel Server, and the script will need to use a fully qualified path, including the machine name, to access the file. NOTE: InvokeMethod is currently supported only for specific methods which have been documented in Siebel Bookshelf. Siebel Systems does not support calling other specialized methods using InvokeMethod. For additional information on using these methods, and on other supported methods with InvokeMethod, refer to Siebel Bookshelf version 7.7 > Siebel Object Interfaces Reference > Interfaces Reference > Business Component Methods > InvokeMethod Method. NOTE: The sample scripts provided are intended only to illustrate use of these methods, not to provide complete implementation-ready functionality. You will need to modify the code for your specific business requirements and test the code carefully before applying on a production environment. Siebel Systems also recommends reviewing Technical Note 514, available on SupportWeb, for general scripting best practices, including recommendations for error handling. Summary Creating a File in the Siebel File System To create a file in the Siebel file system from an external source, use the invokable method CreateFile. Before calling CreateFile, make sure that a new business component record has been created using the NewRecord method for the business component. CreateFile Method and Arguments CreateFile srcFilePath, keyFieldName, keepLink > RetValue CreateFile has the following arguments: 1. SrcFilePath. This is the fully qualified path of the file being used as the source. The file should be accessible to the machine which is running the script, as follows: In Siebel 7, using the Siebel Web Client, the file must be accessible to the Siebel Server. In Siebel 6 and earlier, or in the Siebel 7 Mobile or Dedicated Web client, the file must be accessible to the client which is running the script.

NOTE: If the file is not located on the Siebel Server machine, it may be necessary to map the IP address of the machine where the file is located, as follows: a. On the Siebel Server machine, in the Windows desktop, right mouse click on My Computer, select Map Network Drive. b. Select a drive, for instance, drive k:, and map it to the files machine IP Address such as \\172.20.23.46\d. c. If your code is in Siebel VB, refer to your file as k:\testfile.txt. In eScript, you would refer to your file as k:\\testfile.txt.

page 2 of 6

Technical Note 198: Accessing File Attachments Through Siebel VB, Siebel eScript, and Siebel Object Interfaces

2. KeyFieldName. This is the name of the field in the business component that contains the File Name. a. For example, in the Account Attachment business component, the field name is AccntFileName. b. To determine the correct field name, check in Siebel Tools for the Business Component > Field object. The field whose name includes FileName should be used. 3. KeepLink. This applies only to URLs. The value should be "Y" or "N" depending on whether a link to the file is stored as an attachment instead of the actual file. NOTE: If you want to add a URL to an attachment business component, it is not required to use the CreateFile method. Instead, after creating a new record, the script can add the URL string directly to the file name field using the BusComp.SetFieldValue method. CreateFile has the following return value: RetValue. "Success" or "Error" depending on whether or not the operation succeeded.

CreateFile Example Using Siebel VB Dim RetValue as String Dim fileBC as BusComp

Instantiate fileBC as the appropriate attachment buscomp fileBC.NewRecord NewAfter RetValue = fileBC.InvokeMethod ("CreateFile", "c:\Demo\Image.bmp", "AccntFileName", "Y") fileBC.WriteRecord CreateFile Example Using Siebel eScript var RetValue; var fileBC; //Instantiate fileBC as the appropriate attachment buscomp fileBC.NewRecord(NewAfter); RetValue = fileBC.InvokeMethod ("CreateFile", "C:\\Demo\\Image.bmp", "AccntFileName", "Y"); fileBC.WriteRecord(); NOTE: When using InvokeMethod in eScript, do not attempt to pass an array of arguments. Instead, pass each argument separately. CreateFile Example Using COM Interfaces Dim Dim Dim Dim errCode as Integer Args(2) as String RetValue as String fileBC as BusComp

page 3 of 6

Technical Note 198: Accessing File Attachments Through Siebel VB, Siebel eScript, and Siebel Object Interfaces

Instantiate fileBC as the appropriate attachment buscomp Args(0) = "C:\Demo\Image.bmp" Args(1) = "AccntFileName" Args(2) = "Y" fileBC.NewRecord NewAfter, errCode RetValue = fileBC.InvokeMethod ("CreateFile", Args, errCode) fileBC.WriteRecord Getting a File from the Siebel File System To get a file from the Siebel file system, use the invokable method GetFile. Before invoking GetFile, your script should query for the desired record in the attachment buscomp. The file will be placed in the following location, depending upon the Siebel application version you are running and the client on which the script is invoked: Siebel 7, using the Siebel Web Client: the file will be placed in the temp directory on the Siebel Server machine. Siebel 7, using Siebel Dedicated or Mobile Web Client: the file will be placed in the temp directory on the users local machine. Siebel 6 and earlier: the file will be placed in the temp directory on the users local machine.

If you need to open the file after retrieving it from the Siebel file system, you would need to use a function such as CreateObject in Siebel VB; however, you would need to know which application to use to open the file. For more information on the CreateObject method, refer to Siebel Bookshelf version 7.7 > Siebel VB Language Reference > VB Language Reference > CreateObject Function. GetFile Method and Arguments GetFile keyFieldName > RetValue GetFile has one argument: KeyFieldName. This is the name of the field in the business component that contains the file name. For example, in the Account Attachment business component, the field name is AccntFileName. To determine the correct field name, check in Siebel Tools for the Business Component > Field object. Use the field whose name includes FileName.

GetFile has a return value of RetValue. This is a string containing one of the following: If the operation succeeded, RetValue is "Success, <outFilePath>". OutFilePath is the fully qualified path of the file. If the operation failed, RetValue is "Error".

GetFile Example Using Siebel VB Dim RetValue as String

page 4 of 6

Technical Note 198: Accessing File Attachments Through Siebel VB, Siebel eScript, and Siebel Object Interfaces

Dim fileBC as BusComp

Instantiate fileBC as the appropriate attachment buscomp Query for the desired attachment record RetValue = fileBC.InvokeMethod ("GetFile", "AccntFileName") GetFile Example Using Siebel eScript var RetValue; var fileBC; //Instantiate fileBC as the appropriate attachment buscomp //Query for the desired attachment record var RetValue = fileBC.InvokeMethod("GetFile", "AccntFileName"); Example using COM Interfaces Dim Dim Dim Dim errCode as Integer Args as String RetValue as String fileBC as BusComp

Instantiate fileBC as the appropriate attachment buscomp Query for the desired attachment record Args = "AccntFileName" RetValue = fileBC.InvokeMethod ("GetFile", Args, errCode) Updating a File in the Siebel File System To update a file in the Siebel file system with a newer version of the file, use the invokable method PutFile. Before invoking PutFile, your script should query for the desired record in the attachment buscomp. PutFile Method and Arguments PutFile srcFilePath, keyFieldName > RetValue PutFile has the following arguments: 1. SrcFilePath. This is the fully qualified path of the newer version of the file. The file should be accessible to the machine which is running the script: a. In Siebel 7 Web Client, the file must be accessible to the Siebel Server. b. In Siebel 6 and earlier, or in the Siebel 7 Mobile or Dedicated Web client, the file must be accessible to the client which is running the script. 2. KeyFieldName. This is the name of the field in the business component that contains the file name. a. For example, in the Account Attachment business component, the field name is AccntFileName.

page 5 of 6

Technical Note 198: Accessing File Attachments Through Siebel VB, Siebel eScript, and Siebel Object Interfaces

b. To determine the correct field name, check in Siebel Tools for the Business Component > Field object. The field whose name includes FileName should be used. PutFile has the following return value: RetValue. "Success" or "Error" depending on whether or not the operation succeeded.

PutFile Example Using Siebel VB Dim RetValue as String Dim fileBC as BusComp Instantiate fileBC to the appropriate attachment buscomp Query for the desired attachment record to be updated

RetValue = fileBC.InvokeMethod "PutFile", "c:\Demo\Image.bmp", "AccntFileName" fileBC.WriteRecord PutFile Example Using Siebel eScript var RetValue; var fileBC; //Instantiate fileBC to the appropriate attachment buscomp //Query for the desired attachment record to be updated RetValue = fileBC.InvokeMethod("PutFile", "c:\\Demo\\Image.bmp", "AccntFileName"); fileBC.WriteRecord(); PutFile Example Using COM Interfaces Dim Dim Dim Dim errCode as Integer Args(1) as String RetValue as String fileBC as BusComp

Instantiate fileBC to the appropriate attachment buscomp Query for the desired attachment record to be updated

Args(0) = "C:\Demo\Image.bmp" Args(1) = "AccntFileName" RetValue = fileBC.InvokeMethod ("PutFile", Args, errCode) fileBC.WriteRecord

page 6 of 6

Вам также может понравиться