Extract Email Address from Contact Column
Hi,
I am looking for a way to use Bridge to extract the email address from a contact and update an "Email" column in the same row for a record, when added.
I assume this can be done with Java Script but I have no idea where to start!
Answers
-
Heather Hutchens ✭✭✭
I've had a lot of success by asking ChatGPT these kinds of technical questions - so I thought I would try this one.
I literally typed "In smartsheet..." and then copied and pasted this question in. Following is the response I got. I hope it's helpful - and I also hope it's helpful for the community to know that ChatGPT knows Smartsheet inside and out :)
----------------------------------
To extract an email address from a contact and update the "Email" column in Smartsheet using JavaScript, you can leverage the Smartsheet API and the Smartsheet SDK for Node.js. Here's a general outline of the steps you would need to follow:
- Set up a Smartsheet API access token: You'll need an API access token to authenticate your requests. You can generate a token from the Smartsheet Developer Portal.
- 建立一个内容webhook:创建一个webhook年代martsheet to trigger your JavaScript code whenever a new record is added. You can configure the webhook to send a POST request to your server with the relevant data.
- Set up a server to handle the webhook: You'll need a server to receive the POST requests from Smartsheet's webhook. You can use a server-side JavaScript platform like Node.js to handle this.
- Extract the email address from the contact: In your server-side JavaScript code, you can extract the email address from the contact information received in the POST request payload.
- Update the "Email" column in Smartsheet: Once you have extracted the email address, you can use the Smartsheet SDK for Node.js to update the corresponding cell in the "Email" column for the record. You'll need to identify the row using the information provided in the webhook payload and update the appropriate cell.
Here's a sample code snippet to give you an idea of how this could be implemented using Node.js and the Smartsheet SDK:
const smartsheet = require('smartsheet');
const webhookSecret = 'your_webhook_secret'; // Secret used for webhook verification
const accessToken = 'your_access_token'; // Smartsheet API access token
const smartsheetClient = smartsheet.createClient({
accessToken: accessToken
});
// Handle the webhook request
app.post('/webhook', (req, res) => {
// Verify the webhook request
= req.headers [' x-smartsheet-signat const签名ure'];
if (signature !== webhookSecret) {
res.status(403).send('Invalid signature');
return;
}
// Extract necessary information from the webhook payload
const recordId = req.body.recordId;
const contactEmail = req.body.contact.email;
// Update the "Email" column in Smartsheet
const cellData = {
columnId: 'your_email_column_id', // Replace with the actual column ID for the "Email" column
value: contactEmail
};
smartsheetClient.sheets.updateRow({
sheetId: 'your_sheet_id', // Replace with the actual sheet ID
rowId: recordId,
cells: [cellData]
})
.then(() => {
res.status(200).send('Email updated successfully');
})
.catch((error) => {
console.error('Error updating email:', error);
res.status(500).send('Error updating email');
});
});
Remember to replace the placeholders in the code with your actual values:
your_webhook_secret
,your_access_token
,your_email_column_id
, andyour_sheet_id
.Note that this is just a basic example to give you a starting point, and you may need to adapt it based on your specific requirements and the structure of your Smartsheet data. Make sure to refer to the Smartsheet API documentation and the Smartsheet SDK documentation for more details and additional methods you might need.
Additionally, you'll need to set up a server that listens for incoming requests on the
/webhook
endpoint and configure your Smartsheet webhook to send requests to that endpoint.
Categories
As long as the document is still available in OneDrive, the document should still be available in Smartsheet. Think of it as a URL to a website. As long as the website is still up, it doesn't matter who the owner is.<\/p>"}]}},"status":{"statusID":3,"name":"Accepted","state":"closed","recordType":"discussion","recordSubType":"question"},"bookmarked":false,"unread":false,"category":{"categoryID":343,"name":"Add Ons and Integrations","url":"https:\/\/community.smartsheet.com\/categories\/apps-and-integrations","allowedDiscussionTypes":["discussion","question"]},"reactions":[{"tagID":3,"urlcode":"Promote","name":"Promote","class":"Positive","hasReacted":false,"reactionValue":5,"count":0},{"tagID":5,"urlcode":"Insightful","name":"Insightful","class":"Positive","hasReacted":false,"reactionValue":1,"count":0},{"tagID":11,"urlcode":"Up","name":"Vote Up","class":"Positive","hasReacted":false,"reactionValue":1,"count":0},{"tagID":13,"urlcode":"Awesome","name":"Awesome","class":"Positive","hasReacted":false,"reactionValue":1,"count":0}],"tags":[{"tagID":268,"urlcode":"Attachments","name":"Attachments"},{"tagID":549,"urlcode":"account-and-user-management","name":"Account and User Management"}]},{"discussionID":104380,"type":"question","name":"Questions about Bridge from a potential newbie","excerpt":"We are considering upgrading to Advance, and I have questions about Bridge capabilities: Our project blueprint includes multiple reports that pull entries from master logs based on the job number. This means that our admins have to add the job number to every single new report filter when they set up a project. Can Bridge…","snippet":"We are considering upgrading to Advance, and I have questions about Bridge capabilities: Our project blueprint includes multiple reports that pull entries from master logs based…","categoryID":343,"dateInserted":"2023-04-24T16:40:19+00:00","dateUpdated":"2023-04-24T17:41:23+00:00","dateLastComment":"2023-08-14T17:16:34+00:00","insertUserID":126351,"insertUser":{"userID":126351,"name":"Julie Fortney","title":"","url":"https:\/\/community.smartsheet.com\/profile\/Julie%20Fortney","photoUrl":"https:\/\/aws.smartsheet.com\/storageProxy\/image\/images\/u!1!hZje4WgcMyQ!en9eZ1QFHfo!MFtz_rjuwYj","dateLastActive":"2023-08-18T21:46:54+00:00","banned":0,"punished":0,"private":false,"label":"Overachievers"},"updateUserID":126351,"lastUserID":140451,"lastUser":{"userID":140451,"name":"Brian_Richardson","title":"","url":"https:\/\/community.smartsheet.com\/profile\/Brian_Richardson","photoUrl":"https:\/\/lh3.googleusercontent.com\/a\/AAcHTtdoak7dmkycj4YXWA0KDZnC6qO3ZJMvHnAxo52tsjtiGh4=s96-c","dateLastActive":"2023-08-19T15:11:48+00:00","banned":0,"punished":0,"private":false,"label":"Overachievers"},"pinned":false,"pinLocation":null,"closed":false,"sink":false,"countComments":7,"countViews":319,"score":null,"hot":3374392013,"url":"https:\/\/community.smartsheet.com\/discussion\/104380\/questions-about-bridge-from-a-potential-newbie","canonicalUrl":"https:\/\/community.smartsheet.com\/discussion\/104380\/questions-about-bridge-from-a-potential-newbie","format":"Rich","tagIDs":[369],"lastPost":{"discussionID":104380,"commentID":390521,"name":"Re: Questions about Bridge from a potential newbie","url":"https:\/\/community.smartsheet.com\/discussion\/comment\/390521#Comment_390521","dateInserted":"2023-08-14T17:16:34+00:00","insertUserID":140451,"insertUser":{"userID":140451,"name":"Brian_Richardson","title":"","url":"https:\/\/community.smartsheet.com\/profile\/Brian_Richardson","photoUrl":"https:\/\/lh3.googleusercontent.com\/a\/AAcHTtdoak7dmkycj4YXWA0KDZnC6qO3ZJMvHnAxo52tsjtiGh4=s96-c","dateLastActive":"2023-08-19T15:11:48+00:00","banned":0,"punished":0,"private":false,"label":"Overachievers"}},"breadcrumbs":[{"name":"Home","url":"https:\/\/community.smartsheet.com\/"},{"name":"Get Help","url":"https:\/\/community.smartsheet.com\/categories\/get-help"},{"name":"Add Ons and Integrations","url":"https:\/\/community.smartsheet.com\/categories\/apps-and-integrations"}],"groupID":null,"statusID":3,"attributes":{"question":{"status":"accepted","dateAccepted":"2023-04-26T14:21:28+00:00","dateAnswered":"2023-04-26T02:30:08+00:00","acceptedAnswers":[{"commentID":373252,"body":"
Hey @Julie Fortney<\/a> <\/p> I'll answer what I can and shout out to @Brian_Richardson<\/a> for back up. <\/p> #1 Report Filters- To my knowledge there isn't a direct Report Filter update however I wondered if the column was a dropdown list - if so, Bridge can update dropdown lists and if the filter was set to select all it made me wonder if the filter would pick it up new selections. (Datashuttle also updates dropdown lists if this method works)<\/p> #2 I've had problems with a slow sheet erroring out in Bridge. The sheet was massive and Bridge would time-out. Bridge did not help this sheet (it might have been too large for anything to help)<\/p> #3 -I don't have any experience with Control Center, so sorry, I can't answer those questions<\/p> My fav Bridge solutions?<\/p> -Capturing Approver Names in approval workflows<\/p> -Adding rows - same sheet, different sheets, Child rows to Parents, On a weekly cadence, Adding New rows of acquired data to a status update sheet which feeds into a dashboard report<\/p> -Translating Employee Ideas from their native tongue to English<\/p> -Checking FedEx Tracking Status on a sheet's worth of shipments<\/p> I hope this helps<\/p> Kelly<\/p>"},{"commentID":373322,"body":" Hey @Julie Fortney<\/a> !<\/p> @Kelly Moore<\/a> thanks for the shout out :-) but I'm not sure I can help more than what's already been posted. <\/p> @Julie Fortney<\/a> in general Bridge is an API tool. You can setup multi-branched workflows in Bridge with pre-set API calls and utilities. You can also do custom HTTP calls to any API that you have access to in the cloud. So anything you can do with API calls you can do with Bridge. It also, importantly, allows you to run Javascript code using the results of your API calls, and to trigger workflows on changes to Smartsheet content or on any other webhook that you can receive from other tools.<\/p> There's a fair amount of Smartsheet API methods that are prebuilt into Bridge, but not all of them. So if you're looking at the Bridge documentation for Smartsheet<\/a> integrations and not finding what you need, you can also look at the Smartsheet API documentation<\/a> to see if there's something there to help you out. If you find an API method to use that's not already pre-built as an integration, then you can use the Custom HTTP Call step to directly call the API. You just have to provide the Smartsheet API with an API token, which you can assign to yourself in your Personal Settings.<\/p> It looks like your specific questions were answered pretty comprehensively by Kelly and Samuel but here's my 2c:<\/p>