Slack Block Builder (Function 'getBlocksData' finished with error! JSON for blocks is invalid)

Dear Community,

I received an error in the Slack Block builder module with posting a created message from variables created from Q&A’s from Calendly.

I found the issue, but need to find a way to ignore this certain value.

For your info: Leads from my clients answers some questions in Calendly and unfortunately a lead used “pagebreaks/newlines” in his answers… :expressionless:
The Block builder can’t handle this JSON format…

Below a image how to the text is been filled, it already passed more then 50 leads correctly, those leads didn’t used “pagebreaks or newlines” in the answers.

I try to find a way something like: when a newline is detected replace with \n or ignore or something.

Picture with the variables and the used newlines/pagebreaks in Q&A 1 by the lead:

Does anyone knows anyway how to make this automation future proof?

Your thoughts or ideas will be highly appreciated!

Hello!

What you could do is to use the replace function in your mapping into the Slack block.


you can replace with anything else. You can do it with any mapping of the Q&A answers, instead of mapping directly the fields.

Benjamin

2 Likes

An easy solution, but one that will cost you an operation, is the Transform to JSON module of the default JSON app. Then it doesn’t matter if the end user used pagebreaks, newlines, carriagereturns, tabs, whatever. The module transforms any input to a valid JSON string:

Otherwise, you can use multiple replace functions to account for \n, \r, \t, \f indeed.

Cheers,
Henk

Dear Benjamin,

This was quite easy, thanks!
I placed the replace function in my Q&A variable and it works.

image

1 Like