Skip to main content

Update Client Config Activity

Overview​

You can use the Update Client Config (set_config_form_data) activity in Pia package editor to update the current values of a configuration form that is enabled for a Package or the Global Config form for the specific Client the Activity is run under. With the Set Client Config activity, you can the config values are directly modified as the package executes.

The Update Client Config activity can be located by searching for "Set client config" in the list of activities in the package editor:

Below is the code snippet that shows how you can use the Update Client Config Form activity to modify configurations of a Global Configuration Form:

# Pia Automation Package
conditions:
- name: 'client_filter'
optMode: 'OptOut'
category: 'Hello World'

- name: 'chat'
option_button: 'Set Client Config'
option_text: 'This is a test package.'
option_category: 'Test Category'

steps:
- task: set_config_form_data
inputs:
global: 'true'
form_def: '{"allStaffGroup": "PiaAllStaffGroup1121"}'

Activity Behaviour​

The primary purpose of the Update Client Config activity is to modify the current configuration either for the Global Configuration Form or the form enabled for the package based on the values defined directly in the activity or the values passed from other activities during package execution.

You can define the form type to be modified by using the input parameters such as global, package_id, form_name and form_def. Each of these input parameters have been defined briefly further below in this article.

One requirement to this behaviour is that you will need to define the "variables_form" property in the client filter condition, if you wish to update values for forms other than the global configuration form.

The Update Client Config Activity can be only be used in all package executions (i.e. packages that are initiated via Schedule or Ticketing System Event or the Chatbot).

Input Properties​

Use properties to modify the behaviour of the activity.

Property Name: client_id
Default Value: $Ctx_CW_Client_Id
Property Required: Yes
Property Description: This is the internal client id and will default to the client id for the ticket associated with this package.

Property Name: global
Property Required: 'True' or 'False'
Default Value: False
Property Required: Yes
Property Description: This is to define whether the activity is retrieving values from a global form or a custom form. It will retrieve the formDef from the Client "Global Configuration" that is setup on the Client screen.

Property Name: package_id
Property Required: If global = false, this property is required. If global = true, this property is not required.
Property Description: This will be the GUID of the Package that has the config form on it in the 'client_filter' conditions.

Property Name: form_name
Property Required: If global = false, this property is required. If global = true, this property is not required.
Property Description: This is the static name of the form.

Property Name: form_def
Property Required: Yes
Property Description: This will be a JSON formDef with the Reference Name of each form item.

Property Name: action
Property Required: Yes
Property Options: 'add' or 'replace'
Default Property: 'add'
Property Description: This will be the GUID of the Package that has the config form on it in the 'client_filter' conditions.

Output Properties​

This activity does not have any output property.

Examples​

Here is an example package that updates the value for a configuration form defined for a package:

# Pia Automation Package
conditions:
- name: 'client_filter'
optMode: 'OptOut'
category: 'Hello World'

- name: 'chat'
option_button: 'Set Client Config'
option_text: 'This is a test package.'
option_category: 'Test Category'

steps:
- task: set_config_form_data
inputs:
package_id: '9cc0dc34-d0e0-4eb7-84c5-46c809cd925a'
form_name: 'example_form'
form_def: '{"example_values": "PiaAllStaffTestGroup"}'

Here, the activity updates the value of the defined field in the given package configuration form which you can check by going into the package configuration section of the Clients screen in Pia: