handling objects

Hello everyone,

I am facing an issue with handling objects in Retool and would appreciate your support.

In my scenario, I am using a database query to set data:


The problem arises when I retrieve the content of artikelnummer. When I use {{artikelnummer.value}} without an additional space, the output in the CSV file appears as {"Art-57198"}. However, if I add a space before or after {{artikelnummer.value}}, it is correctly displayed as Art-57198, but with the unwanted space.

I want to achieve the correct format (Art-57198) but without the extra space. Does anyone have an idea on how to implement this?

For illustration, here is the output when I only use {{artikelnummer}}:


Thank you in advance for your help!

Hi David!

Certainly! Here are some suggestions for what could be causing this issue and how to implement a solution:

1. Whitespace in Data: It's possible that there is some extra whitespace (e.g., leading or trailing spaces) in the value retrieved from {{artikelnummer.value}}. This could explain why adding a space before or after the value changes its appearance.

Solution: You can use a function to remove leading and trailing spaces from the value before displaying it in the CSV file. In JavaScript, you can do this with the trim() function. For example: {{artikelnummer.value.trim()}}.

2. JSON Formatting: Because the value {"Art-57198"} is in JSON format, when you add a space before or after, it might be interpreted as a string, removing the JSON formatting.

Solution: If you want to remove the JSON formatting and display only the string, you can use the JSON.parse() function to parse the JSON and extract the string value: {{JSON.parse(artikelnummer.value)}}. This will give you the string "Art-57198" without any additional spaces.

3. CSV Formatting: The behavior could also be related to how the CSV file is interpreting the data. Sometimes, CSV readers may interpret data differently based on formatting.

Solution: Ensure that your CSV file settings or import settings are configured to handle data without considering extra spaces as part of the value. Check if there are any settings in your CSV generation process that might be causing this behavior.

By applying these suggestions, you should be able to achieve the correct format (Art-57198) without the unwanted space in your CSV file.