Skip to main content

Creating a new record type

To enable a custom Appian application to interact with the ABBYY FlexiCapture Connector for Appian, you will need to create the entities described below. Prior to creating these entities, make sure that the ABBYYFlexiCapturePlugin.jar plug-in is installed on the Appian server. To install the plug-in on the Appian server, simply copy it from the connector distribution package into this folder: APPIAN_INSTALL/_admin/plugins/. Now you need to:

Creating an AFC_GetConstantDSEByRecordTypeName rule that will return a constant of type “Data Store Entity”

The CreateRecord method of the Web API requires a rule that returns constant of type “Data Store Entity.” This rule will determine the data store and data type where a record should be created.
  1. In Appian Designer, open the application and click New → Expression Rule.
  2. Select Create from scratch, complete the Name and Save In fields, and click Create & Edit.
  3. In the Rule Inputs dialog box, click the + icon and create a new input variable of type “Text” and name it “RecordTypeName”.
  4. Paste the following code into the code editor on the left:
if(ri!RecordTypeName == "New Records", /* In the RecordTypeName parameter, specify the name of the new record type in the plural.  */
cons!New_Constant, /* After cons!, specify the name of the constant of the record type. */
null /* If there is more than one record type in the application, replace "null" with the same "if" condition as above, specifying the name of the second record type and the name of its constant. */
)
If an input RecordTypeName is the same as the name of a stored record type (in the plural), the DataStoreEntity constant will be returned that links the data store and the data type.

Creating an AFC_GetDataTypeByRecordTypeName rule that will return the full name of the data type

The CreateRecord method of the Web API requires a rule that returns the full name of the data type.
  1. In Appian Designer, open the application and click New → Expression Rule.
  2. Select Create from scratch, complete the Name and Save In fields, and click Create & Edit.
  3. In the Rule Inputs dialog box, click the + icon and create a new input variable of type “Text” and name it “RecordTypeName”.
  4. Paste the following code into the code editor on the left:
if(ri!RecordTypeName == "New Records", /* In the RecordTypeName parameter, specify the name of the new record type in the plural, the full name of the data type, and the namespace of the record type. */
'type!{urn:com:appian:types}NewDataType',
null
/* If there is more than one record type in the application, replace "null" with the same "if" condition as above, specifying the name of the second record type. the full name of the data type, and the namespace of the record type. */
)
If an input RecordTypeName is the same as the name of a stored record type (in the plural), a string will be returned containing the full name of the data type; otherwise, null will be returned (you can look up the namespace in the data type properties). To display the properties of a data type, open the desired data type in the ABBYYFlexiCapture application. Clicking the name of the data type in the top left corner will open the Data Type Properties window where you can see the namespace.

Creating a Web API method for adding a new document to the knowledge center

  1. In Appian Designer, open the application and click New → Web API.
  2. Enter “UploadDocument” (without the quotes) into the Name and Endpoint fields. Change HTTP Method to POST and click Create & Edit.
  3. Close the template selection dialog box and paste the following code into the code editor:
with(
local!value: http!request.body,
a!httpResponse(
statusCode: 200,
headers: {},
body: uploaddocument(local!value)
)
)
The uploaddocument(String query) method will be displayed in the code editor only if there is a ABBYYFlexiCapturePlugin.jar file in APPIAN_INSTALL/_admin/plugins/. This method sends a JSON string with the file contents directly to the JAVA method you created and gets back a JSON string with the ID of the folder where the document was placed.

Creating a Web API method for populating the database table

  1. In Appian Designer, open the application and click New → Web API.
  2. Enter “CreateRecord” (without the quotes) into the Name and Endpoint fields. Change HTTP Method to POST and click Create & Edit.
  3. Close the template selection dialog box and paste the following code into the code editor:
with(
local!value: cast(
rule!AFC_GetDataTypeByRecordTypeName(http!request.queryParameters.RecordTypeName),
a!fromJson(http!request.body)
),
a!writeToDataStoreEntity(
dataStoreEntity: rule!AFC_GetConstantDSEByRecordTypeName(http!request.queryParameters.RecordTypeName),
valueToStore: local!value,
onSuccess: a!httpResponse(
statusCode: 200,
headers: {
a!httpHeader(name: "Content-Type", value: "application/json")
},
body: a!toJson(
fv!storedValues
)
),
onError: a!httpResponse(
statusCode: 500,
headers: {
a!httpHeader(name: "Content-Type", value: "application/json")
},
body: a!toJson(
{
error: "There was an error writing to the data store"
}
)
)
)
)
  • The rule!AFC_GetDataTypeByRecordTypeName(http!request.queryParameters.RecordTypeName) rule will accept as input a parameter with the name of the record type (received by the Web API method from the ABBYY FlexiCapture Connector for Appian) and return the full name of the data type.
    • The rule!AFC_GetConstantDSEByRecordTypeName(http!request.queryParameters.RecordTypeName) will return the Data Store Entity constant.
  1. In the right-hand pane, click the New Query Parameter button and add a new parameter named RecordTypeName into the query string. Finally, select the Set as default test value option and click Save.