Remove non printable characters in input text/para field.

Certified Senior Developer

Hi ,

I have a set of non printable characters in DB as number and we use char function and concat function to combine in a single string and used strip function to remove it from text. Now the requirement is to replace text with space. I tried substitute function and others which is not working as expected. Please someone guide me here

a!localVariables(
  local!specialCharacterIds: rule!SUF_QueryRecordType_getSpecialCharacters(),
  local!specialCharacters: joinarray(
    a!forEach(
      local!specialCharacterIds,
      char(fv!item)
    ),
    ""
  ),
  a!paragraphField(
    label:"Comment",
    value:ri!comment,
    saveInto: {
      ri!comment,
      a!save(
        ri!comment,
        substitute(save!value,{local!specialCharacters}," ")
      )
    }
  )
)



  Discussion posts and replies are publicly visible

Parents
  • 0
    Certified Lead Developer

    I tried to replicate your requirement.
    Make changes to your code accordingly.

    a!localVariables(
      local!specialCharacterIds: { 9, 10, 13, 160, 8203 },
      /* Tab, LF, CR, NBSP, Zero-width space */
      local!sampleText: "John" & char(9) & "Wick" & char(10) & "Test" & char(13) & "Data" & char(160) & "End",
      /* Convert IDs to actual characters */
      local!specialCharacters: a!forEach(
        local!specialCharacterIds,
        char(fv!item)
      ),
      {
        a!textField(
          label: "Comment",
          value: reduce(
            fn!substitute,
            local!sampleText,
            local!specialCharacters,
            " "
          ),
          readOnly: true
        )
      }
    )


    Let me know if this works for you.

Reply
  • 0
    Certified Lead Developer

    I tried to replicate your requirement.
    Make changes to your code accordingly.

    a!localVariables(
      local!specialCharacterIds: { 9, 10, 13, 160, 8203 },
      /* Tab, LF, CR, NBSP, Zero-width space */
      local!sampleText: "John" & char(9) & "Wick" & char(10) & "Test" & char(13) & "Data" & char(160) & "End",
      /* Convert IDs to actual characters */
      local!specialCharacters: a!forEach(
        local!specialCharacterIds,
        char(fv!item)
      ),
      {
        a!textField(
          label: "Comment",
          value: reduce(
            fn!substitute,
            local!sampleText,
            local!specialCharacters,
            " "
          ),
          readOnly: true
        )
      }
    )


    Let me know if this works for you.

Children
No Data