Passing User Information In BloX Post Action
Objective
Send the user information along with data in a BloX Post payload without additional data security or dimension transformation.
Method
This method uses the following BloX components:
- A widget script
- A text input field
- A standard post action
HIGH-LEVEL OVERVIEW
We start by creating a Post Action and creating an attribute that will hold the user information in the data payload.
Next, we create a text input field that will accept the active user's information in its value. This field will be hidden from view, so it only exists to pass information to the action.
In the widget script, we will access the user's information and assign it to the hidden input field's value.
Implementation
ACTION SETUP
Create an action that follows similar syntax to:
{
"type": "ActionSet",
"actions": [
{
"type": "Action.Submit",
"action": "post",
"url": "<Your webhookURL>",
"title": "test",
"data": {
"emailAddress": ""
}
}
]
}
The emailAddress value will be dynamically populated by the active user's address.
INPUT FIELD SETUP
Next, we create the input field in one of our body containers:
{
"type": "Input.Text",
"id": "data.emailAddress",
"class": "emailToData",
"title": "emailToData",
"placeholder": "",
"style": {
"display": "none"
}
}
Let's review the attributes.
type will generate the input field and allow us to grab a value.
id will allow the action to identify this field as the one that fills the emailAddress attribute in the payload.
class will allow us to modify the class' value with the user's email address.
title is optional.
placeholder is optional.
style will hide the element from the page.
id will allow the action to identify this field as the one that fills the emailAddress attribute in the payload.
class will allow us to modify the class' value with the user's email address.
title is optional.
placeholder is optional.
style will hide the element from the page.
WIDGET SCRIPT SETUP
Finally, we edit the BloX script attribute.
widget.on('ready', ()=> {
$('.btn.btn__text', element).click(()=>{
$('.emailToData').attr('value', prism.user.email);
})
})
The bold portion of the script above asks Sisense what the current user's email address is and assigns it to the value attribute of our hidden input field. It can then be passed to the data object when the action is triggered.
If you wish to pass another field repeat the above steps for each additional field.
Cheers!
Updated 03-02-2023
intapiuser
Admin
Joined December 15, 2022