CNG services (form population)
As of the release of the Generic Service Builder, the functionality of CNG Services and the CNG Service Builder has become obsolete. Keep in mind that some of the documentation might be partially outdated.
Step-by-step guide
- What is a CNG service?
- Creating a CNG service
- How to populate a form with form events and CNG service
- How to populate a form using a CNG service in the workflow builder
- How to populate a form upon form population button click
What is a CNG service?
CNG service is provided by CNG application to invoke an external service and populate a form. Invoking service has to be a CNG compatible service which has pre-defined input message format and output message format based on JSON internally. Input to a CNG service should be a JSON message representing a form and it's answer values and the output will be a JSON message which can refill the properties of the received form. CNG service accepts the form with update answer values and updates the same form with the values returned from the CNG service. Detailed technical information about the message formats exchanged can be found at Compose form population API.doc
CNG services are primarily used in 3 major occasions.
- Populating a form under form events
- Populating form using a CNG service in the workflow builder
- Populating a form under a form population button click
An example CNG service is deployed at https://cnginttest.more.no/example-integration-service with a operation name "populatePersonDetails" and credentials (test,123456).This will accept a valid ssn and return name,address,postalCode,firstName,lastName fields which are aliases of the form instance from which the CNG service is referred. Valid ssn numbers for this service are (28118749822,11111111111 ,03013500168).
Through out this article example-integration-service is used to visualize the usage of a CNG service.
Creating a CNG service
Before a CNG service is availbale for use it has to be designed through the Compose designer.
In the top tool bar please press the Create CNG service button to create the CNG service.
Enter a name for the CNG service and Click Ok
Double click on the created CNG service to configure.
Enter the remote service URL, mountpoint, username and password in the settings tab and save.
Click on the set Up operations tab to configure operations under the remote service.
Click on add operation tool bar icon to configure operations.You can add multiple operations.
Enter remote operationName and operation type. Currently only one type of operation is supported. You can chose to override remote operation name with a new name. This is useful if the operation name is changed after service is originally created and enables you to override the operation name without changing the service url.
Click save and then start to start the CNG service to make it available to other components.
Starting the service can also be performed from repository view as well
How to populate a form with form events and CNG service?
Lets try to use the aforementioned "ExampleCNGservice" to populate a form under the form event onAnswerComplete.
Since the Example CNG service is expecting a form with ssn, name, address, postalcode, firstName, lastName as aliases in the fields of the form "Employee" form is created to reflect the scenario.
Since the form is going to use the created CNG service, an input variable has to be created to link the service to the form. Click on "Input Variables" tab.
Click on the Create button () to create the input variable to refer the CNG service.
Enter a name of the input variable and click Ok.
Double click on the input variable to open the input variable properties and change the type to "CNG Service Variable" and OK then Save
In the form click on the SSN field to define a form event.
In the SSN fields properties panel press Manage Events on create new event to define the form event.
Under Event chose OnAnswerComplete, and select Call CNG service as the action.
Then chose the input variable which refers the CNG service you want to call and click Ok. Save and version the form.
Create a sample workflow with a start point, a form, an end point. In the form activity properties, browse to select the form and form version according to the form you created.
Then click on Manage Input variables to attach the ExampleCNGservice to the form.
In the popup dialog window chose the input variable related to CNG service and click Browse
Chose the ExampleCNGservice we have previously created.
Chose the operation and click Ok.
You will now see that your selected CNG service is attached to the form input variable. Click Ok.Then save and version the workflow and start the workflow version
When you start a workflow session, enter a valid SSN in the SSN field(28118749822) and leave the SSN text field, you will find remaining fields are populated from the CNG service invocation.
How to populate a form using a CNG service in the workflow builder?
Form population can be done from the workflow builder directly. If you use the same form created earlier, you will have to remove the form event created under SSN field in the form builder and version the form again. We will use the new form version without form event in this example. Create a workflow with a form response activity and attach the form version without form events. Select Populate via service to attach the ExampleCNGservice created earlier.
Click Browse and chose the CNG service you want to invoke.
Chose the operation you want to use ,click OK and then Save.
In this case the SSN has to be pre poulated by a static value or a previous value (from the authentication or other form activity) in the workflow. In this case the pre population is done in static manner.
Select the form activity and click on Pre Populate Question Answers.
Chose the SSN field from the form data model to prepopulate and click Ok
Enter the static value for SSN (28118749822). (If you prefer to use a value from a different form activity you need to add another form activity to the workflow and place this before the current form in the workflow. You would also have to select the Value from workflow option in the prepopulation panel.) Click Ok.
When you run the workflow you will find that the SSN is pre populated along with the other fields that were pre populated from the CNG service execution.
How to populate a form upon form population button click?
You can insert a form population button in a form and fill the fields in the same form using a CNG service.
Create a new form as in above 2 scenarios , with an additional Button. Please add the form population button and attach the CNG service based on the input variable as depicted in the above examples.
It is not required to add form events. Follow " How to populate a form with form events and CNG service?" section to see how to map the input variable to ExampleCNGservice in the workflow builder.
In the respondent UI you add the SSN and click on the Button.You will find that the other form fields are populated from the CNG service, in this case ExampleCNGservice.