Tips, Tricks & Best Practices

ChrisChiha
Top Contributor

Split property value into 2, based on comma

SOLVE

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!

0 Upvotes
2 Accepted solutions
Levi
Solution
Top Contributor | Elite Partner
Top Contributor | Elite Partner

Split property value into 2, based on comma

SOLVE

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. 


Bureau Vet

Did my post solve your question? Help the community by marking it as a solution

View solution in original post

ChrisChiha
Solution
Top Contributor

Split property value into 2, based on comma

SOLVE

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 

View solution in original post

0 Upvotes
4 Replies 4
Levi
Solution
Top Contributor | Elite Partner
Top Contributor | Elite Partner

Split property value into 2, based on comma

SOLVE

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. 


Bureau Vet

Did my post solve your question? Help the community by marking it as a solution
ChrisChiha
Solution
Top Contributor

Split property value into 2, based on comma

SOLVE

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 

0 Upvotes
KcChano22
Participant

Split property value into 2, based on comma

SOLVE

@ChrisChiha can you show us to do that JS custom code please?

0 Upvotes
ChrisChiha
Top Contributor

Split property value into 2, based on comma

SOLVE

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
    }
  });
}