Store Package Data Activity
Overviewβ
The Store Package Data Activity (store_package_data) is one of the built-in features available in the Pia Package Editor. This activity allows you to store certain information in the database during package execution so that it can be retrieved later when required.
An example scenario where this activity is currently used in Pia is the Staff Offboarding Package. In this package, the offboarded user's information is saved in the database using the Store Package Data Activity so that if the user account needs to be re-enabled in the future, the information can be re-retrieved.
The Store Package Data Activity can be located by simply searching for "store" in the list of activities in the package editor:
Here is a basic example of a package where the Store Package Data Activity has been used:
# Pia Automation Package
conditions:
- name: 'client_filter'
optMode: 'OptOut'
category: 'Hello World'
- name: 'chat'
option_button: 'Test Package'
option_text: 'This is a Test Package.'
option_category: 'Test Category'
steps:
- task: chat_interaction
alias: get_data
inputs:
text: 'Add the username and phone number you wish to save: '
form_name: 'details_form'
form_display_mode: 'Embed'
- task: inline_powershell
alias: store_data
inputs:
username: =get_data.form.username
number: =get_data.form.number
script: |
$data = @{
number = $number;
} | ConvertTo-Json -Depth 5
Write-Host $data
[string]$key = $username.ToString()
Write-Host $key
return @{ data = $data; key = $key}
- task: store_package_data
inputs:
key: =store_data.key
value: =store_data.data
- task: chat_interaction
inputs:
text: 'The user information has now been saved.'
In the above example, the package will save the phone number entered into the form and the key would be the username. Below is the output in the chatbot:
Activity Behaviorβ
The primary purpose of this activity is to temporarily hold package data so that it can be extracted in the future when required. Using the Store Package Data Activity, you can store data using a unique key which can be referred to when retrieving the data using the Get Data Activity.
The data stored by the Store Package Data Activity is on a per package basis. By default, data will be stored against the current package, but you may modify the activity to store the data against other packages. This data is also isolated to the sandbox or live mode (if you store data while running your package in a sandbox, the values will not be available when your package is used in live mode).
The Store Package Data Activity can be used in all types of package executions. This includes packages which have been initiated via the Pia Chatbot or via Ticketing System Event.
Input Propertiesβ
Use properties to modify the behavior of the activity.
Property Name: key
Property Required: Yes
Property Description: A unique key to store this information for later retrieval
Property Name: value
Property Required: Yes
Property Description: Value to store
Property Name: package_internal_id
Property Required: No
Property Description: Package to store data against. If you do not specify, this will default to the current executing package
Output Propertiesβ
There is no output property available for this activity.