This article explains how to use the createButton function to create an interactive button that triggers a webhook in PowerAutomate. By clicking this button, a flow is triggered that transmits and processes specific data.
Description
The createButton function allows the creation of an interactive button in Smenso. This button executes a defined action when clicked, such as sending HTTP requests (webhooks). In this example, a webhook in PowerAutomate is executed to generate and send a report.
Syntax
createButton(state, title, tooltip, action, [borderColor], [fillColor], [textColor], [successMessage], [failureMessage], [icon])
Example
The following example formula creates a button that triggers a webhook in PowerAutomate:
createButton(
"1",
"Generate Report",
"Clicking this button will create and send the report",
"HTTPPost('https://example.logic.azure.com/workflows/your-workflow-id/triggers/manual/paths/invoke?api-version=2016-06-01&sp=/triggers/manual/run&sv=1.0&sig=your-signature',
'application/json; charset=utf-8',
JSONPackage(
'projectID', projectGuid,
'ID', guid,
'title', title,
'Date', formatDate(flavor('Date'),'MM/dd/yyyy'),
'Details', flavor('Report-Details'),
'Recipient', getUserEMail(),
'Created on', flavor('Created on')
))",
"",
"",
"",
"The report will be sent to you shortly via email at "+getUserEMail(),
"",
"envelope"
)
Parameters
| Parameter | Description |
|---|---|
state |
Defines whether the button is active (1) or inactive (0). |
title |
The title of the button, displayed on the button itself. |
tooltip |
An optional tooltip text that appears when the user hovers over the button. |
action |
Defines the action to be executed, such as an HTTP request (webhook). |
successMessage |
A message displayed when the button action is executed successfully. |
icon |
An icon displayed on the button. In this example: envelope. |
Functionality
- When clicked, the button sends an HTTP (POST) request to the specified webhook in PowerAutomate.
- The request includes a JSON payload containing dynamic data from Smenso fields such as
projectID,title, andDate. - The flow in PowerAutomate processes the received data and performs the desired action, such as generating and sending a report.
Notes
- Ensure that the webhook in PowerAutomate is correctly set up and accessible.
- Verify that all required fields in the workspace are defined before using the function.
- The
iconparameter is optional but can be used to improve visualization.
Comments
0 comments
Please sign in to leave a comment.