The Laserfiche SDK is a powerful software development toolkit that allows you to extend your enterprise content management capabilities with the creation of custom solutions. It is the same programming interface that Laserfiche developers use to develop all client-facing applications. Here are some ways to use the Laserfiche SDK.
The Laserfiche SDK comes with different library types to choose from.
Laserfiche Server Objects (LFSO) – allows you to do everything that the Laserfiche Client and Administration Console can do when communicating with the Laserfiche Server.
- Example: If you need to create a script that automatically updates the metadata on a series of documents, you can use LFSO.
Document Processor – deals with importing/exporting documents, converting image formats and OCRing text.
- Example: If you are writing a utility that a user can run in order to import a batch of documents into the Laserfiche repository, you can use Document Processor.
Client Automation Tools – allows ECM integrators to control and interact with the Laserfiche Windows Client
- Example: If you would like display invoices in the Laserfiche Windows Client corresponding to a particular Product Number from within your Accounting Application, you can use Client Automation Services.
- Note: Client Automation Tools is a .NET replacement for the previous Client-interaction mechanism, ImageEnable. It includes support for handling multiple Client instances, working with Snapshot, managing toolbars and launching business processes, as well as other enhancements.
.NET: Repository Access – enables third-party applications to communicate with the Laserfiche Server. It ships with an ADO.NET provider that allows the repository to be queried as a structured data source (more about this later on in this article).
- Example: If you would like to run a script from within your Accounting System that automatically stamps invoices in Laserfiche with the “Approved” stamp, you can use Repository Access.
.NET: Document Services – provides services for importing, exporting, OCRing and other operations related to Laserfiche repositories.
- Example: If you are writing a utility for importing documents into Laserfiche you can use Document Services.
PDF Exporter – allows conversion of Tiff images to PDF documents during export from Laserfiche.
- Example: If you are writing a script to export Tiff images and convert them to password-protected PDFs you can use PDF Exporter.
Java Repository Access (JRA) – mostly for document management with no admin functionality as of yet.
Use each of the libraries in the following situations:
- LFSO/Document Processor libraries– If you are already familiar with LFSO or are using unmanaged code.
- .NET libraries– If you are new to the Laserfiche SDK, as these are more condensed than the LFSO/Document Processor libraries.
- JRA libraries– If you are used to working with Java.
Detailed information about each of the libraries along with code examples can be found in the Laserfiche SDK help files that come with your Laserfiche SDK installation.
Once you’ve decided which libraries to use, make sure to follow these six steps for creating a robust Laserfiche SDK project:
- Create a connection to the Laserfiche Server or share an existing connection.
- Lock the documents before working on them in order to prevent other users from modifying them at the same time. Locking the document first improves server performance by preventing a potential notification overhead that results from a document auto-locking.
- Perform the actions on the documents.
- Save the changes.
- Release the locks on the documents.
- Release the connection.
Laserfiche Query Language (LFQL)
You can use the Laserfiche SDK to query the Laserfiche repository with Advanced Search Syntax (described thoroughly here) or LFQL – an internal custom Laserfiche query language with a structure and functionality similar to SQL. The results returned by the LFQL queries can then be used in your ECM integrations or workflows.
The Laserfiche virtual tables, which define the range of information that you can query, are a major component of the LFQL. Each repository has its own set of virtual tables structured like relational database tables.
You would like to retrieve a list of entries that have the “Purchase_Order” template assigned to them which were modified after they were created. The following LFQL query returns the name, entry ID, created and modified dates of each of those entries.
SELECT entry_name, entry_id, created_date, last_modified from lf.entry WHERE pset_name = 'Purchase_Order' AND last_modified > created_date
Here is this query in the context of a C# code sample using Repository Access.
LfConnection conn = new LfConnection(mySess);
LfCommand lfqlCommand = conn.CreateCommand();
// Find all entries that are assigned the General template.
lfqlCommand.CommandText = "SELECT entry_name, entry_id, created_date, last_modified from lf.entry WHERE pset_name = 'Purchase_Order' AND last_modified > created_date";
Laserfiche.RepositoryAccess.Data.LfDataReader reader = lfqlCommand.ExecuteReader();
if (reader.HasRows) // non-zero result set
System.Windows.Forms.MessageBox.Show("Entry Name:" + reader["entry_name"].ToString() + " | Entry ID:" + reader["entry_id"].ToString());
Note: if you are using Laserfiche Server 8.0/8.1, the LFCR_PRIV_READ_ACCESS privilege or the LFCR_PRIV_BYPASS_FILTER privilege is necessary to execute any LFQL query.
Language Integrated Query (LINQ)
LINQ is a Microsoft technology that essentially establishes a single, universal language to query data, no matter what the data source is.
- The Repository Access LINQ provider generates LFQL queries from LINQ expressions and executes them using the Laserfiche ADO.NET provider.
- These type of queries are easier to put together than LFQL queries, as they require less knowledge of the specific syntax, and your integrated development environment (such as Microsoft Visual Studio) can help you build them.
Here is an example of an LFQL query written using C#:
RepositoryContext context = new RepositoryContext(mySess);
IEnumerable res = from pages in context.Pages
where pages.HasText == false
foreach (PageRow row in res)
var id = row.EntryId;
var pg = row.PageNumber;
Detailed LINQ syntax can be found in the Laserfiche SDK help files that come with your Laserfiche SDK installation.
Researching Laserfiche for your organization? Get a free demo and decide if Laserfiche is right for you!