In this procedure the tasks necessary to allow users to attach files to an object on the client, selecting that file from the client’s file system, are provided. This functionality includes the use of an Add transaction to create a new file object and to capture the properties of that object, including the file to be attached, from the user. A transaction screen set is defined that includes a filed to display the external data property. The field for this property type displays a file dialog to the user when it is selected in the wizard, allowing the user to navigate to the file to be attached.
The synchronization of this data includes steps that update the back end system with the information about the file, including it’s name, the parent object it is attached to, and other information as may be required by the back end system. Typically this information is updated to the back end using a step definition of the type matching that back nd, i.e., a Java, SQL, or HTTP-XML step. A document management step is defined to perform the actual file upload and back end processing necessary to store that file in the location or repository where files are to be stored.
When the transaction is created, assuming the properties from the object were all selected in the add transaction wizard, there will be matching properties in the new transaction definition. In subsequent steps, a property to capture the parent object’s key property value is added to this transaction. First, the initial value of the FileName property must be defined to capture the name of the file on the client device.
If these attributes are set, the file dialog on the Agentry Client will present only those files and file types defined in the File Filters list, and will prevent users from selecting the files found in the Restricted Files. This is optional behavior and is not a requirement of this functionality. However, it is recommended that options for these attributes be at least considered to prevent users from attaching files that should not be transferred, e.g., executables, resource files, etc.
With the change to the property’s initial value attributes, and the definition of the rule, the FileName property within the transaction is now defined to capture the name and extension of the selected file as stored on the client device. The rule contains a simple structure consisting of the FILE_NAME function that takes the external data property (File in the Mobile Northwind example) as it’s single parameter, returning the name of the file it references.
In the Mobile Northwind example application the step is defined to be used by the transaction AttachDoc. The name of this step is CommitCustomerDoc. Next document mappings for this new step must be defined.
Once the document mapping is defined, the Agentry Server will process the file as that mapping dictates, including which property contains the file, how to provide the file to the document management step’s command, and whether or not to clear the file from the file system when processing is completed.
When this command is defined, the file is first added to the repository and then subsequently committed to the repository. This is a required set of operations for Subversion. Other version control systems will handle new files differently. This processing assumes the file did not exist in the repository prior to this operation. If files are to be updated in any system, Subversion or others, the order of operations would be different. In general this command should be written only with a full understanding of how the back end stores files and how different situations are handled, e.g., new files vs. updates, etc.
When this procedure is complete, users will have the ability to navigate to and select files on the client device. These files are then attached to the parent of the file object. During synchronization, the transaction processing will include uploading the file to the Agentry Server and then storing that file in the back end system
copy <<my.FileName>> to <,FileTransfer.RepositoryDirectory>>
add <,FileTransfer.Repository>>\<<my.FileName>> to repository
commit <<FileTransfer.Repository>>\<<my.FileName>> to repository