Correct parameter to remove (replace) section of text in a string in db field

Hey all,

Simplified a workflow by adding each new text item in a string, now when the user deletes this selection i’d like to remove it from the string.

So right now, I might have:

item1, item2, item3, item4

I can easily keep adding new items.

I’m looking at an update query, and using the ‘Replace String’ formatter. I can search for ‘item3’ for example, but need to ensure I remove the entire section, e.g. ', item3 - so the field is ready for new additions.

What would be the correct ‘Replace with’ parameter property to use to remove the above?

Would ‘’ do it?

UPDATE: I can confirm this kind of works, but it does leave behind the ‘’ within the db field, and if I remove this and replace with a space then I’ll just add additional spaces between each records. Not the biggest deal - but if anyone has the right parameter or approach to remove a text item from a string that would be appreciated.

I don’t know here, but is it possible to store this as an array in your db?

Hey Philip, I don’t have an array field type in the DB, so just used string type and format it with split to convert it to an array to display the results. Am I missing an option in the DB?

I don’t know, I thought I saw it the other day in some post/blog/Google search but it wasn’t want I was looking for so just glanced over it…so not sure if it’s possible, but I’d throw it out there

1 Like

Thanks Philip, I recollect seeing something similar, perhaps it’s the JSON field. I’ll do some digging. Right now it’s a 99% solution, but would like something that’ll handle the space character that will be continually created. Perhaps one more formatter to remove the white space will do it.

Also, id try with your current solution, going into the code view with the replace string you’ve used, and remove the ‘’ and leave as blank (or blank in between the special characters)

I find that sometimes you need to tweak what’s in the code view because entering things in the UI will often treat them as text and put the ’ ’ around. For instance if you type null it will treat it as text and make it ‘null’. But if you go into code and just right null it treats it as the null value.

Having edited the expression manually so the replace expression is simply ‘’ - as @Philip_J suggested, you could add another replace to remove any double spaces. If there is a possiblity that item1 would need to be removed, you would need to modify the expression a little.

Once you have clicked the Select button to save the replace step in the Data Formatter, you can edit the code it produces in the data binding view.

And change the code from
$_POST.industry_experience_ids.replace('-item3', ' ')
$_POST.industry_experience_ids.replace('-item3', '')

1 Like

Another option is:


I’ll usually use this for making minor changes or to copy the code for example (it saves a click).

1 Like

You guys rock, thank you! Have edited the output and removed the space :slight_smile: