Submit an Application Form
Use Case
Submit an application form for an existing application as part of a defined application process.
Prerequisites
- The ID of an existing application at the correct process state to submit an application form
This example will involve using the REST API
Retrieve Form Config & Process Rule ID
Our first step is to retrieve the configuration of the form so we know which values will need to be filled in for the submission to be successful.
We’ll also need to get the ID of the associated process rule that should run when the form is submitted.
For this example, we will assume that the application form is marked as a default progress action in the process flow that the applicant is in.
import requests
import json
# Authentication details for target system
username = "user"
password = "password"
# The ID of the application to which we are submitting a form
app_id = 318
url = "https://your-system.tal.net/vx/api/v1/applications/{}".format(
app_id)
headers = {"accept": "application/json"}
# Retrieve the applicant's process information
response = requests.get(url, auth=(username, password),
headers=headers)
form_id = None
rule_id = None
if(response.ok):
jData = json.loads(response.content.decode('utf-8'))
for process_rule in jData["process_state"]["rules"]:
if (process_rule["default_action"] == "progress") and (process_rule["action_type"] == "WCN::DBIC::AbstractForm::ApplicationForm"):
# If we have an application form process rule as a default progress action, store the form & process rule ids
rule_id = process_rule["id"]
form_id = process_rule["form_id"]
else:
print("No valid process rule available for this application.")
quit()
else:
# Display the http error code along with the description
response.raise_for_status()
Submit the Form
Once we have our form configuration, we have the information we need to prompt the user to fill in the necessary details before the form can be submitted.
In this example, we assume the user has provided the relevant values for each field in the form and represent this input in the form_contents variable.
The form in the code snippet is an extremely basic example with three fields: “Skills”, “Languages” & “Hobbies”
url = "https://your-system.tal.net/vx/api/v1/applications/{}/form/{}?processRuleId={}".format(
app_id,
form_id,
rule_id)
# Contents of an extremely basic form example.
form_contents = {
"fields": [
{
"id": 83277,
"values": [
{
"value": "Resilience, good communication & commercial awareness",
"instance": 1
}
]
},
{
"id": 83285,
"values": [
{
"value": "English, French",
"instance": 1
}
]
},
{
"id": 83293,
"values": [
{
"value": "Fishing, Cycling",
"instance": 1
}
]
}
]
}
# Submit the application form
response = requests.post(url, auth=(username, password),
headers=headers, json=form_contents)
if(response.ok):
jData = json.loads(response.content.decode('utf-8'))
print(json.dumps(jData, indent=4,))
else:
response.raise_for_status()