I am new to Retool and i have a situation where i build an app for users to log merchant pricing concession. This request needs to go into a review status and the problem i am facing, i want to create a URL that will link this specific page where the pricing request was made and send it to Slack in order for the reviewer to approve the pricing request. I added a id field to my base table and create a SQL query where i select all and added a where clause parameter id = id but its not working as attempted.
Did someone do this before and have any tips
On to make this simpler?
1 Like
@Clarise Welcome to the community ![:wave: :wave:](https://community.retool.com/images/emoji/apple/wave.png?v=12)
Not sure how your setup looks like, but here is an idea on how you can do it.
- Pass URL Parameters: Include
id
and currentUser
in the URL.
- Extract & Use Parameters: Extract these parameters in the detailed view and use them in your query and logic.
- Send to Slack: Generate a URL with the required parameters and send it via Slack
1. Generate URL with Parameters
In your primary app where the request is logged:
const id = requestForm.data.id; // Retrieve the ID of the submitted request
const currentUser = currentUser.email; // Assuming currentUser object has the email property
const detailPageURL = `https://your-retool-domain.com/apps/PricingRequestDetail?id=${id}&user=${encodeURIComponent(currentUser)}`; // Encode user info in URL
// Send to Slack (assumes you have a hooked up API or integration)
const slackMessage = `A new pricing request needs your review: ${detailPageURL}`;
sendToSlack(slackMessage); // Implement this function based on your Slack integration
2. Extract URL Parameters in Detailed View App
In the PricingRequestDetail
app( Create a new Retool app that will serve as your detailed view for the pricing request. This app will take an id
as a URL parameter and display the details of the request.), extract the id
and user
parameters from the URL:
const id = utils.getQueryParam('id');
const user = utils.getQueryParam('user'); // This will get the current user if passed in the URL
Use these parameters to fetch the relevant data:
SELECT *
FROM PricingRequests
WHERE id = {{ id }};
You can also use the user
parameter for any specific user-related logic if required.
3. Function to Send Slack Message
Ensure your sendToSlack
function sends the correctly formatted message to Slack via a webhook or API:
const slackWebhookURL = "https://hooks.slack.com/services/T00000000/B00000000/XXXXXXXXXXXXXXXXXXXXXXXX";
function sendToSlack(message) {
fetch(slackWebhookURL, {
method: 'POST',
headers: {
'Content-type': 'application/json'
},
body: JSON.stringify({
text: message
})
});
}
Example Button Trigger
submitButton.onClick(() => {
const id = requestForm.data.id; // Retrieve the ID of the submitted request
const currentUser = currentUser.email; // Assuming currentUser object has the email property
const detailPageURL = `https://your-retool-domain.com/apps/PricingRequestDetail?id=${id}&user=${encodeURIComponent(currentUser)}`; // Encode user info in URL
const slackMessage = `A new pricing request needs your review: ${detailPageURL}`;
sendToSlack(slackMessage); // Implement this function based on your Slack integration
});
Hope this general example helps with the logic ![:sun_with_face: :sun_with_face:](https://community.retool.com/images/emoji/apple/sun_with_face.png?v=12)