Processing Data Contexts

One of the more powerful features of system addons is the ability to process sets of related data known as data contexts. A data context consists of one or more pieces of data that are all in some way related. For example, the primary type of data context used by ILLiad and addons developed for ILLiad is the transaction data context. Each transaction data context consists of the transaction, user, and (potentially) lender information associated with a given transaction. The addon system allows for batch processing of lists of data contexts by providing the user with a method that can be called to tell the system what data contexts the addon wants to process, and how it wants to process them. More specifically, system addons have access to the ProcessDataContexts method, which takes three parameters: contextIDType, contextIDs, and methodName. The contextIDType parameter defines the type of identifiers that will be passed in using the contextIDs parameter. The valid values for the contextIDType, as well as the expected value types for the contextIDs parameter, differ depending on the host application. The list of host applications that currently have contextIDTypes defined, as well as the values they accept and the values contained in resulting data contexts are listed below. The third parameter, methodName, identifies the name of the method that the system should call for each data context. Inside of this method, the addon can access data related to the current data context just as it can during a system event by use of the GetFieldValue, SetFieldValue, and SaveDataSource methods.

Processing Data Contexts Sample

function Init()
    RegisterSystemEventHandler("Route", "InitiateCustomRouting");
end

function InitiateCustomRouting()
    ProcessDataContexts("transactionstatus", "Awaiting Request Processing", 
	"HandleContextProcessing");
end

-- This method will be called once for every transaction that is currently at
-- the Awaiting Request Processing status.  It will take each request and move
-- it to specialized queue based on whether it is an article or a loan request.

function HandleContextProcessing()
    if (GetFieldValue("Transaction","RequestType") == 'Article') then
        ExecuteCommand("Route", GetFieldValue("Transaction", 
		"TransactionNumber"), "Awaiting Article Request Processing");
    else
        ExecuteCommand("Route", GetFieldValue("Transaction", 
		"TransactionNumber"), "Awaiting Loan Request Processing");
    end
end

Supported Context ID Types

System Manager

  • TransactionNumberThe contextIDs parameter must be one or more transaction numbers. If more than one transaction number is passed, the numbers must be in a lua table by using the following syntax: {13562, 12356, 14567}. The list can also be built programmatically so long as the actual value passed in is a one dimension table where all the values are integer transaction numbers.
  • TransactionStatusThe contextIDs parameter must be the name of a single transaction status. Partial names such as 'Cancelled by' or 'On Hold Until' where the end of the status can be several different things are allowed.