Appian Community and Appian Academy are being upgraded. From July 24–August 3, the Appian Community will be in read-only mode. During this time, the site will be read-only and user registration will be disabled. We apologize for any inconvenience this may cause, but a more secure, stable, and performant Community experience is coming soon!

The new Appian Community launches August 3, followed by Appian Academy on August 7. During the migration, Appian Community Edition, Appian Academy, Documentation, Certifications, Instructor-led Customer Training, Partner Sales Training & Accreditation, and Forum (for Appian Partners and Customers only) will remain available.

Substitute function not working with commas

Certified Associate Developer

I have the following which i saved as a process variable of type text

{ "userId": "abc123", "submissionId": "111222333", "createdDt": "2022-06-17T04:07:19.611Z"}

I want to remove spacing between the commas and colons, trying to do so with substitute(pv!text, ": ", ":") and substitute(pv!text, ", ", ","). It works for the colon, but not for the comma, so the result is the following

{ "userId":"abc123", "submissionId":"111222333", "createdDt":"2022-06-17T04:07:19.611Z"}

Also, when i use stripwith(pv!text,","), the comma can be affected and removed. Wondering why substitute cant do the same.

Any ideas as to why this is happening or how else I can remove the space between the comma?

  Discussion posts and replies are publicly visible

Parents Reply Children
  • 0
    Certified Associate Developer
    in reply to Stefan Helzle

    Hi Stefan, I realised that the space after the comma is char(10), but on top of that, it seems that substitute(ri!json, char(10), "") would actually result in the char(10) being replaced by a space instead. The work around that works would be to replace char(10) with a character, then subsequently replace that character. For example:

    substitute(substitute(substitute(substitute(substitute(
      tostring(
        ri!json
      ),concat(char(10)," "),"this_is_char(10)"),
      "this_is_char(10) ",""),", ",",")," : ",":"),", ",",")

    Thanks for the input up till now, greatly appreciate it!

  • 0
    Certified Lead Developer
    in reply to zacha0002

    This seems to be a tremendous effort ....

    Depending on the system that created this JSON, a line-break can be represented by char(10), char(13) or char(10)&char(13). I think this is what you see.