Document Management API Code Snippet - Add Documents with Metadata
FileHold is a .NET 2.0 / 3.0 C# based system designed around a scalable, highly configurable web services oriented architecture.
This blog post features a useful code snippet that shows how you can add a document to the FileHold document management software system via the FileHold web services based API.
For those who do not understand what a code snippet is - this is an example of how to use code - not an entirely self contained piece of software.
============================
The Document Manager class has a method AddDocument and one of the
parameters is a array of FieldWithValues structure.
// ----------- code snippet
// get the fields definition for the schema
FieldDefinition[] fielddefinitions =
DocumentSchemaManager.GetDocumentSchemaFields( SchemaId );
//create the new schema values for the document
ListfieldsWithValues = new List ();
//for each schema field
foreach ( FieldDefinition field in fielddefinitions )
{
// only do for NON system fields
if ( !field.IsSystem )
{
FieldWithValue newFieldValue = = new
FieldWithValue();
//global field id
newFieldValue.FieldId = field.MetadataFieldId;
// define variable ob type object
object value = null;
// and now based on the field type assign the value
// if you want to assign default value
// value = field.InitialValue;
// if it is string
// value = "text of the metadata"
// if it is date
// DateTime dt = new DateTime( 2008, 4, 12 );
// value = dt;
// in case of dropdown menu
// get the menu items into array
// DropdownFieldChoice[] menuchoices =
DocumentSchemaManager.GetDropDownMenuItems(field.MetadataFieldId);
// // set the default null value
// value = new int[] { };
// foreach (DocumentSchemaManagerService.DropdownFieldChoice menu in
menuchoices )
// {
// if (menu.Value == YOU_MENU_FIELD_VALUE )
// {
// value = new int[] { menu.Id };
// break;
// }
// }
// set the value
newFieldValue.FieldValue = value;
// add the field value to the list
fieldsWithValues.Add( newFieldValue );
}
}
// now you can use the fieldsWithValues variable in the AddDocument method
// ----------- end of code snippet
Labels: API, back up document management software, FileHold API, FileHold Document Management Software, imaging, imaging integration
