Skip to main content
Announcements
Qlik Introduces a New Era of Visualization! READ ALL ABOUT IT
cancel
Showing results for 
Search instead for 
Did you mean: 
André
Contributor III
Contributor III

"Special" Char replacement in Automation

I'm currently trying to write a string to a 'set load script' block and am attempting to cleanse the string before insertion into the load. My struggle is getting a string such as "hello','world" to load correctly, but when it is sent to the load script, the single quotes affect the script.

So I am trying to replace the " ' " character with U+2019 ( ’ ), but the single quote also seems to affect the replace function in automations. I attempted to escape the character in the function but then it doesn't do the replace.

Expected behavior:
{$.inputs.form.fqbnp} = hello','world
{replace: {$.inputs.form.fqbnp}, ''', '’'}

Output should be: hello’,’world
But is instead: {replace: hello','world, '''', '’'} as a string

So my question is, how do I 'cleanse' a string/have it as a literal string when used in a load script. How do I reference a comma for replacement in QAA.

This is what the 'Replace' dialog looks like in the UI when I create it:
Andr_0-1708045755789.png
And then when I confirm, and 'Edit Formula' again on it, it changes to this:

Andr_0-1708053767407.png

 

Many thanks!

Labels (3)
1 Solution

Accepted Solutions
AfeefaTk
Support
Support

Hi @André 

I have done this using a custom code block.

There might be other simpler methods to solve this using the existing formula.

For now, try the automation shared below and let me know your feedback.

Thanks

 

View solution in original post

5 Replies
André
Contributor III
Contributor III
Author

Bump 👀

salmankojar
Creator
Creator

Can you share me your Automation Json and also the exact output you require. Sorry but i couldn't understand your requirement properly..

AfeefaTk
Support
Support

Hi @André 

I have done this using a custom code block.

There might be other simpler methods to solve this using the existing formula.

For now, try the automation shared below and let me know your feedback.

Thanks

 

André
Contributor III
Contributor III
Author

This is perfect, can't believe I didn't think about the custom code block! Thank you! 😊

paulcalvet
Partner - Specialist
Partner - Specialist

Hello @AfeefaTk ,

Do you plan to correct this bug ? Use a custom code block to replace character is a little bit complicated no ? 

Thanks for your code, I've been trying to replace a \ for 1 hour 😨

Paul