|
idpobj=new("idp")
The idp object is designed to manage documents stored in inbound source libraries that support IDP documents. These libraries are supplied documents from configured inbound sources such as email and monitored directories, or can also be supplied documents programmatically or via upload, using the idp object. The documents are identified by library, type, and doc ID, but these values are system-controlled. Inbound libraries are staging repositories for documents that will ultimately be transferred to document archive libraries in the UnForm archiving system. Properties are maintained using the 'document data' feature of UnForm libraries, and then used as identification and data values when the documents are transferred.
The idp object is also used to maintain IDP job definitions.
Many of the document-related methods are duplicated in the idpdoc object as a convenience.
Properties
lasterr contains an error number if the last method encountered an error to be reported.
|
lasterrmsg$ contains an error message if the last method encountered an error to be reported
|
inputtokens, outputtokens, seconds report the usage of the last AI API call
|
fullresponse$ contains the entire response from the last AI API call, before the response is parsed into definition-specific data
|
sizerror, rateerror, retryseconds return error reasons: sizeerror=1 indicates the input file is too large for the model, raterror=1 indicates rate limiting is imposed by the AI API, and requests should be paused retryseconds.
|
Inbound Source Methods
These methods are generally used only by the UnForm server internally when maintaining inbound source records.
count() returns the number of inbound source records.
|
delete(id$) removes the source record id$.
|
exists(id$) returns true (1) if the source id$ exists.
|
get(id$,prop$) fills the prop$ template with the record for source id$. Property fields include id$, description$, inactive$, type$, source$, emserver$, empassword$, emmanager$, emallowfrom$, emtimeout$, action$, actionoption$.
|
libname$(id$) returns the library pathname of the source id$, used when access to a library object for the library is required.
|
put(id$,prop$) adds or updates the source record id$ with data in the prop$ template.
|
range$(first,count[,flds$]) returns a tab-delimited range of source records, starting with a 1-based index, for up to count records. Optionally specify a list of fields.
|
Job Definition Methods
These methods relate to job definition and are generally used by the UnForm browser interface rather than in code. They are described here for completeness.
joblist$(asjson) returns a list of job names, descriptions, and inactive flag. This will be a tab-separated list, unless asjson is included and is non-zero, in which case the list is returned as a JSON array.
|
getjob(jobid$,json$) fills json$ with a JSON structure of the job definition. The method returns 1 on success, 0 on error.
|
putjob(jobid$,json$) writes the job's JSON structure to the file idp/jobid.dat. Note that JSON structure is internally maintained, so you should generally not use this method to avoid corrupting a job definition. The method returns 1 on success, 0 on error.
|
deljob(jobid$) removes the job definition.
|
jobheader(jobid$,prop$) fills the prop$ properties string template with header information about the job.
•prop.id$ is the job name or ID
•prop.description$ is the description
•prop.instructions$ is the job-level instructions to include in the prompt when posting to the AI API
•prop.model$ is the default AI model
•prop.altmodels$ contains a comma-separated list of alternate models that can be used to resubmit a document through AI
•prop.inactive is 1 if the job is inactive, 0 if active
•prop.autotransfer is 1 if the job should auto-transfer documents that pass validation tests, enabling exception-only handling
•prop.enableoverwrite is 1 if the job can overwrite existing subids when transferred, 0 if sequencing should be used
•prop.prompt$ is the name of the prompt template to use
•prompt.codeinitialize$, prompt.codefields$, prompt.codeidentification$, prompt.codefinalize$, prompt.codepreupload$, prompt.codepostupload$ contain custom code for the referenced sections of the job definition.
|
jobfields$(jobid$,fields$[,detail]) fills fields$ with a linefeed-delimited list of field ids, or if detail=1, a tab-separated list of field ids, names, source type, field type, data type, validation expression, extra field instructions, value expression, and a flag if the field is a grid column in IDP Documents. To conform with TSV formatting, tabs and line breaks are replaced with spaces.
|
jobfield(jobid$,fieldid$,prop$) fills the prop$ string template with field properties (does not replace tabs and line breaks with spaces).
•prop.id$ is the field id
•prop.name$ is the field description, functions as a concise name for the AI engine
•prop.source$ is "auto" for AI-generated data, "user" for user-entered or locally calculated data
•prop.type$ is "field" for a regular data field, "table" for table data, or "column" for a column of the previous "table" field
•prop.datatype$ is the type of data: text, longtext, memo, number, date, lookup=definition, checkbox=options, radio=options, select=options, inlinetable=columns
Lookups are defined in Script Libraries.
•prop.instructions$ is the extra field-level instructions for the AI engine
•prop.validation$ is the validation definition validation(arguments...) (validations are defined in Script Libraries)
•prop.value$ is an expression used to calculate local field values. If blank and the job definition is run, user-entered values are retained.
•prop.iscolumn is 1 if this field should be a column in the IDP Documents table, 0 if not
|
jobidentication(jobid$,prop$) fills the prop$ string template with job identification data, used to populate archive property and indexing information used when documents are transferred to an archive library.
•prop.library$ is the library to transfer to
•prop.doctype$ along with prop.docid$ will uniquely identify the document in the library
•prop.docid$ is the unique document within the document types in the library (i.e. doctype Invoice, docid 12345)
•prop.subid$ is the id of the file uploaded to the document, such as "Scan"
•prop.title$ is the title of the document in the library
•prop.categories$ is a line-feed separated list of tab-delimited segments that provide category indexing (multi-level) of the document
•prop.keywords$ is a line-feed separated list of keywords used for important-word indexing of the document
•prop.entityid$ is the entity id for the document, used to match with external users' entity ids when external users login to UnForm
•prop.notes$ contains text notes for the document
•prop.links contains line-feed separated link values to other documents or URLs, where other documents are provided in pipe-delimited syntax of library|doctype|docid[|subid]
|
Document Related Methods
These methods related to specific documents in an inbound source library. Where id$, doctype$, and docid$ values are specified, these refer to the working library document identification rather than the ultimate target library identification. The source id$ refers to the inbound source identifying name rather than the library itself. The doctype$ and docid$ values are the auto-generated values used to identify the documents while they reside in the inbound source library. The docid$ value is visible in the IDP Documents interface, as the ID column, and both doctype and docid values can be seen when browsing the source library through the archive browser interface (these libraries are only visible to administrators). The doctype$ value is based on the date the document was imported from the inbound source, in yyyy-mmdd format. The docid$ value is a day value plus time-based sequence values, in the format mmdd-####-####.
assignto(id$,doctype$,docid$[,userid$]) assigns the specified document to userid$, or de-assigns it if no userid$ is supplied. De-assigned documents are in the pool of available documents that image manager users can self-assign.
|
createdoc(id$,docprop$) creates a new document in the source library, and fills docprop$ with its default properties, so that docprop.doctype$ and docprop.docid$ are valid to further set up the inbound document in the source library.
|
deldoc(id$,doctype$,docid$) removes a document from the inbound source library.
|
delfield(id$,doctype$,docid$,name$) removes a specific custom data field from the document.
|
getdoc(id$,doctype$,docid$,prop$) loads prop$ with the underlying library document properties, using the library object. Note this data differs from the getdocdata() method, which produces document identification data to be used when transferring to an archive library. For example the doctype and docdata properties from this method hold inbound source library document type and id, which are auto-generated by the createdoc() method as documents arrive from their respective inbound sources.
|
getdocdata(id$,doctype$,docid$,data$) loads data$ with the document identification properties that will be used when the document is transferred to an archive library. Template values include library$, doctype$, docid$, subid$, subtitle$, title$, notes$, categories$, keywords$, and links$.
|
getdocdataitem$(id$,doctype$,docid$,item$) returns the value of one document data identifier. Items can be library, doctype, docid, subid, subtitle, title, notes, categories, keywords, and links.
|
getdocdataitem(id$,doctype$,docid$,item$,value$) fills value$ with the value of a specified document data item. Returns 1 if the item is found.
|
getfield$(id$,doctype$,docid$,name$) returns the custom field data named name$.
|
getfield(id$,doctype$,docid$,name$,value$) fills value$ with the custom field name$ data.
|
getfields$(id$,doctype$,docid$) returns a tab-separated values list of custom field names and values.
|
getmeta$(id$,doctype$,docid$,name$) returns the metadata value of name$. Metadata items are read-only values created at the time a document is imported from a source, such as subject and from addresses of email sources, or file names of directory sources. Each name is prefixed with "@".
|
getmeta(id$,doctype$,docid$,name$,value$) fills value$ with the metadata value for name$, such as @subject, or @filename.
|
getmetas$(id$,doctype$,docid$) returns a tab-separated values list of metadata names and values.
|
getsubdoc(id$,doctype$,docid$,subid$,prop$) fills the library object subdoc properties in prop$.
|
getsubdoc(id$,doctype$,docid$,subid$,prop$,imagefile$) fills the library object subdoc properties in prop$, and also creates a file with the image of the subdoc and provides the filename in imagefile$.
|
initinvaliditems(id$,doctype$,docid$) initializes all validation error messages for the document.
|
initinvaliditems(id$,doctype$,docid$,item$) initializes the validation error message for a single item$, which can be a docdata property name or a custom field name.
|
mergedocs$(id$,doclist$) joins the images and properties of the documents in doclist$. The doclist$ value should be tab-separated-value list of doctypes and docids in the inbound source library. The second and later documents in the list are added to the first, so that images are appended as additional pages, notes are appended, and categories, keywords, and links are merged. The function returns tab-separated doctype and docid of the combined document, which is simply the first document type/id in doclist$.
|
movetosource(id$,doctype$,docid$,tosrcid$[,newdoctype$,newdocid$]) transfers a document from the source id$ to a different source tosrcid$. The document is removed from the original source, and begins the normal processing defined for the new source, such as AI or IM processing and job execution. If the newdoctype$ and newdocid$ arguments are provided, they will return the values in the new source library.
|
putdoc(id$,doctype$,docid$,prop$) updates document properties in the underlying library, using the library object. Note this differs from the putdocdata() method, which updates properties related to document identification when a document is transferred to an archive library.
|
putdocdata(id$,doctype$,docid$,data$) updates document identification data with values in the data$ template. Template values include library$, doctype$, docid$, subid$, subtitle$, title$, notes$, categories$, keywords$, and links$.
|
putdocdataitem(id$,doctype$,docid$,item$,value$) updates a specific docdata item, such as library or title.
|
putfield(id$,doctype$,docid$,name$,value$) updates a custom field name$ with the supplied value$.
|
rotatepage(id$,doctype$,docid$,page,degrees) rotates a page (all pages if page=0).
|
splitpage(id$,doctype$,docid$,atpage) splits the PDF document at the page specified, and submits the two documents for processing.
|
transfer$(id$,doclist$[,logfile$]) transfers the documents specified in doclist$ to their respective target libraries with the document properties defined as document data and fields. The doclist$ value should be a line-feed delimited list of tab-separated doctype and docid values in the inbound source library. Each doctype/docid pair identifies an inbound document to transfer. Only documents that have no validation errors are transferred. Before each document is transferred, if a job is assigned to the document, its preupload code is executed. Likewise, after the transfer, its postupload code is executed.
The method returns a log of the transfer, with a line for each document. If logfile$ is supplied, the log is written to the named file.
|
validatedoc(id$,doctype$,docid$) performs all validation tests on the document's identification data and fields. If there is a job assigned to the document, its validation rules are used. Otherwise, the minimum validation required is performed, requiring library and doc type data.
|
|