How i can substitute the ";" for " " , because already tried with substitute() and i can't do anything

For example I made a process where I send an email that already has an html template and replace the input with a dictionary with data to be sent. But when it is sent my table that is in the template gets ";" over the table as I'm going to show you here.



The process basically uses an expression rule to bring the data and it brings like this:

Someone knows why he put the ";"

  Discussion posts and replies are publicly visible

  • 0
    Certified Senior Developer

    Hi Tiago,

    Can you please let us know how send email node is configured?  Are you displaying any data above your table in the Email (HTML) template ?

  • +1
    Certified Lead Developer

    Substitute() will only work for characters actually contained within your text.  In this case, your text presumably doesn't contain the ";" character itself, as this is inserted automatically by Appian whenever rendering an array into plaintext.  I'm not sure what your current code is so it's hard to guess at exactly what the best solution might be, but you will probably want to use a looping function or at least something that specifically deals with arrays. 

    The easiest is "joinArray()", which allows you to automatically concat together all items in the passed-in array, separated by whatever character you designate.

    joinArray(
      pv!myCdtArray.description,
      " "
    )

    For more advanced use cases, you should iterate over the array using a!forEach(), as this allows you to do item-by-item processing when necessary.

    a!forEach(
      items: pv!myCdtArray,
      expression: fv!item.description & if(fv!isLast, null(), " ")
    )
    /* the above is functionally identical to joinArray(), but is easy to expand to handle other use cases which joinArray() cannot */

  • 0
    A Score Level 1
    in reply to Shikha

    I dont have more data than this :  , and the node i just have : =

    a!forEach(
      items: rule!P2P_sandBoxTiago(),
      expression: "<tr>" & "<td>" & fv!item.processId & "</td>" & "<td>" & fv!item.typeOfRequest & "</td>" & "<td>" & fv!item.requester & "</td>" & "<td>" & fv!item.createdOn & "</td>" & "<td>" & fv!item.description & "</td>" & "<td>" & fv!item.type & "</td>" & "</tr>"
    )

  • Mike's suggestion is correct here, you will want to joinarray() around the forEach() building your HTML for the email.

    joinarray(
        a!forEach(
          items: rule!P2P_sandBoxTiago(),
          expression: "<tr>" & "<td>" & fv!item.processId & "</td>" & "<td>" & fv!item.typeOfRequest & "</td>" & "<td>" & fv!item.requester & "</td>" & "<td>" & fv!item.createdOn & "</td>" & "<td>" & fv!item.description & "</td>" & "<td>" & fv!item.type & "</td>" & "</tr>"
        ),
        ""
    )

  • 0
    Certified Lead Developer
    in reply to Tiago Sousa

    Cool, thanks for confirming.

    As a tag-on note, this is a good example of where it can be tremendously helpful to create a new Expression Rule to generate your desired output text, simply give it a rule input of your data type (array) and pass that in from the process model.  Then in the Expression Rule Editor you can generate test data (either with a query or manually) and get an instant preview of what the generated text / HTML / etc will look like.  The added benefit of this method is, if you ever need to make updates, you can just update the expression rule instead of having to make Process Model edits - and the change will take effect immediately (even for running instances of the process model).