Sample Script
Quick Fields contains a powerful Script Editor that enables you to write VB.NET and C# scripts. In the sample script below, a message box is displayed to the user after a page is processed. The code in red represents the custom script.
The method associated with the script's event (OnAfterPageProcessed) accepts a single parameter that is defined for you: e. You can use e to access most of the methods, properties, interfaces, etc. that you will need to interact with the page, document, and session. The options available to you within a script depend on the event you have selected. For example, you cannot access the name of a document class in an event that occurs before the document in question is identified. As another example, you could not use Laserfiche Server Objects to interact with the active document until after it is stored in the repository (until the OnDocumentStored method is called). In addition, the available options also vary depending on whether the event you have selected is associated with a page (e.g., OnPageCreated) or a document (e.g., OnDocumentCreated).
Show me the script in VB.NET.
Imports System
Imports System.ComponentModel
Imports Laserfiche.QuickFields.Scripting
Imports Laserfiche.QuickFields.Scripting.Events
Namespace QuickFields.Scripting
'''<summary>
'''Provides one or more methods that can be executed when a Quick Fields event occurs.
'''</summary>
Partial Public Class Script1
' The ShowMessageBox, ShowErrorBox, ShowDialog, and WriteMessage functions, accessible
' through the e.API property, are available to help debug your scripts.
'''<summary>
'''This method executes when the After page processed (Page.Processed.After) event occurs.
'''</summary>
'''<param name="e">Contains data about the page processed event.</param>
<ScriptEvent("Page.Processed.After")> _
Public Sub OnAfterPageProcessed(ByVal e As AfterPageProcessedArgs)
e.API.ShowMessageBox("Hello world!")
End Sub
End Class
End Namespace
Show me the script in C#.
namespace QuickFields.Scripting
{
using System;
using System.ComponentModel;
using Laserfiche.QuickFields.Scripting;
using Laserfiche.QuickFields.Scripting.Events;
///<summary>
///Provides one or more methods that can be executed when a Quick Fields event occurs.
///</summary>
public partial class Script1
{
// The ShowMessageBox, ShowErrorBox, ShowDialog, and WriteMessage functions, accessible
// through the e.API property, are available to help debug your scripts.
///<summary>
///This method executes when the After page processed (Page.Processed.After) event occurs.
///</summary>
///<param name="e">Contains data about the page processed event.</param>
[ScriptEvent("Page.Processed.After")]
public void OnAfterPageProcessed(AfterPageProcessedArgs e)
{
e.API.ShowMessageBox("Hello world!");
}
}
}
Tip: For more detailed sample scenarios and code samples, see the white paper on the Laserfiche Support titled Extending Quick Fields 8: Scripting.