We use cookies to make HubSpot's community a better place. Cookies help to provide a more personalized experience and relevant advertising for you, and web analytics for us. To learn more, and to see a full list of cookies we use, check out our Cookie Policy (baked goods not included).
Oct 13, 2022 3:37 AM
Hello,
We have a property field that contains 2 values seperated by a comma. I would like to get the value of the property field that is before the comma only.Is there a way to achieve this?
For example:
Property value: Spain, Madrid
I want to fetch "Spain" from the property value and put it in another property to be used in a workflow later.
Thanks!
Solved! Go to Solution.
Oct 13, 2022 9:31 AM
Hi @ChrisChiha , maybe use the format data action in workflows. See this link. Otherwise export the propertie to Google Sheets or Excel and use the text to columns function with seperator ','. And than import the 2 colomns again in the right propertie.
Oct 16, 2022 7:30 AM
Hey @Levi ,
Thanks!
The export option worked for existing data.
I created a js cusotm code for all new added stuff to have it scalable for the future. the js code will look for the comma and take everything before that comma and store it in a different property field!
Best Regards!
@ChrisChiha
Oct 13, 2022 9:31 AM
Hi @ChrisChiha , maybe use the format data action in workflows. See this link. Otherwise export the propertie to Google Sheets or Excel and use the text to columns function with seperator ','. And than import the 2 colomns again in the right propertie.
Oct 16, 2022 7:30 AM
Hey @Levi ,
Thanks!
The export option worked for existing data.
I created a js cusotm code for all new added stuff to have it scalable for the future. the js code will look for the comma and take everything before that comma and store it in a different property field!
Best Regards!
@ChrisChiha
a week ago
@ChrisChiha can you show us to do that JS custom code please?
Thursday
Hey @KcChano22 ,
Voila: (This code is basically splitting the property field "street" at the comma, and taking the first value and storing it in an output field.
You can then copy the output value to a another property field of your choice.)
const axios = require('axios');
exports.main = async (event, callback) => {
const street = event.inputFields['street']
var shortstreet = street.split(",")[0]
callback({
outputFields: {
proposal_street: shortstreet
}
});
}