[error] remove characters from elements in a multi select field

[error] remove characters from elements in a multi select field

Hi,

I have stringlist variable (multi select field) containing different elements, such as type1, type2.
I had to import excel data in this field and because of input variations I now end up having similar elements but with or without special characters around them: type1,[type1],(type1), type2, (type2), etc.

I would like to remove the brackets in the example above (so as to end up with harmonised elements) but I am not sure how to do that. I managed to get the following:
  1. for each tobeupdated in Ricci_Droit_Form [Statut_FR == "Publiable"]
    {
    olist=tobeupdated.BRANCH;
    ghostlist=olist;
    for each element in olist
        {
            if(element.contains(")"))
            {
                elementx=element.toString();
                updatedelement=elementx.remove("(");
                updatedelement2=updatedelement.remove(")");
                olist.removeElement(element);
                updatedelement3=updatedelement2+".";
                olist.Add(updatedelement3);       
            }
            else
            {
            }
        }
    tobeupdated.BRANCH=olist;
    }




















However, when I run this script from a stateless form, the following error appears:
  1. Error details:
    Error occured while executing on click script.
    Unable to update data on the form variable
    Error occured.



Could anyone help?

Best