Hi all, I need some help trying to figure out how to structure my dynamic search results into a template.
Basically the function is I have someone who searches for one or multiple cities in my app. Those results get put into a user specific text column. From there I need those dynamic results to basically fit into this format: City eq ‘CITY1’ City eq ‘CITY2’ City eq ‘CITY3’.
Currently my data is comma separated: Los Angeles,Anaheim,Claremont,Irvine
Reason being is this is how I need to structure the data for my api call. I’m having a hard time trying to wrap my head around how to structure this or what to use. I tried using GPT to create a javascript code that would take that text and convert it into the format I needed, disclaimer I don’t know how to code lol (Couldn’t get it to work) → Here is the code:
window.function = function (p1) {
if (p1 && p1.value) {
let cities = p1.value.split(',');
if (cities.length === 1) {
return `City eq '${cities[0]}'`;
} else {
return cities.map(city => `City eq '${city.trim()}'`).join(' or ');
}
} else {
return undefined;
}
}
Lastly, I did get it to work using the generate text feature but that is eating up more usage then I would like. I would prefer to get this done either using a computer column or javascript if possible. Any help is appreciated!
