# Script transform apply to whole table, not just visible part

**URL:** <https://forum.inductiveautomation.com/t/script-transform-apply-to-whole-table-not-just-visible-part/107235>\
**Category:** Ignition\
**Tags:** perspective\
**Created:** [June 10, 2025, 3:46pm UTC](https://forum.inductiveautomation.com/t/script-transform-apply-to-whole-table-not-just-visible-part/107235 "2025-06-10T15:46:37Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![Alejandro\_Alaco](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/alejandro_alaco/32/59849_2.png) [@Alejandro\_Alaco](https://forum.inductiveautomation.com/u/Alejandro_Alaco)\
**Post date:** [June 10, 2025, 3:46pm UTC](https://forum.inductiveautomation.com/t/script-transform-apply-to-whole-table-not-just-visible-part/107235/1 "2025-06-10T15:46:37Z")

</div>

Hello!

I´ve got a script transform to aply to a table so show me the text on UTF-8 format...

```python
def transform(self, value, quality, timestamp):

 
    if not isinstance(value, list):
        return value  

    transformed_data = []
    
    for row in value:
        new_row = {}
        for key, val in row.items():
            # Check if the value is of type bytes and decode it
            if isinstance(val, bytes):
                try:
                    val = val.decode('utf-8')
                except UnicodeDecodeError:
                    val = str(val) # Fallback if decoding fails
            new_row[key] = val
        transformed_data.append(new_row)
    
    return transformed_data

```

I just realize, it just show me formated the text loaded on the current table page, If I filter and load othr part of the table it doesn´t come formated.

Any solution for this issue you can think of?

Cheers!

---

<div class="post-metadata">

**Author:** ![djs](https://avatars.discourse-cdn.com/v4/letter/d/e47774/32.png) [@djs](https://forum.inductiveautomation.com/u/djs)\
**Post date:** [June 10, 2025, 7:04pm UTC](https://forum.inductiveautomation.com/t/script-transform-apply-to-whole-table-not-just-visible-part/107235/2 "2025-06-10T19:04:37Z")

</div>

Can you post a screenshot of what you're seeing that is different than expected?

---

<div class="post-metadata">

**Author:** ![pascal.fragnoud](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pascal.fragnoud/32/24728_2.png) [@pascal.fragnoud](https://forum.inductiveautomation.com/u/pascal.fragnoud)\
**Post date:** [June 10, 2025, 8:17pm UTC](https://forum.inductiveautomation.com/t/script-transform-apply-to-whole-table-not-just-visible-part/107235/3 "2025-06-10T20:17:32Z")

</div>

You can pass an `errors` parameter to `decode`, to tell it what to do if it can't decode some bytes.  
In your case, I'd say `errors='ignore'` or maybe `errors='replace'`.

Put something like that in your lib (If you're using it for display purposes in a table, it's likely you'll use it in other places):

```python
def decode_bytes(value, errors='ignore'):
    """Decode bytes to UTF-8 string with configurable error handling.
    
    Args:
        value: The value to decode (bytes or other type)  
        errors (str): How to handle decoding errors ('ignore', 'replace', 'strict')
        
    Returns:
        str: Decoded string if input was bytes, otherwise returns input unchanged
        
    Example:
        >>> decode_bytes(b'Hello World')
        'Hello World'
        >>> decode_bytes(b'Bad \xff bytes', errors='replace')  
        'Bad � bytes'  
        >>> decode_bytes('Already a string')
        'Already a string'
    """
    if isinstance(value, bytes):
        return value.decode('utf-8', errors=errors)
    else:
        return value

```

Then your transform can be just this:

```python
def transform(self, value, quality, timestamp):
	if not isinstance(value, list):
		return value
	return [
		{
			k: some_lib.decode_bytes(v)
			for k, v in val.items()
		} for val in value
	]

```

I like making transform as simple as possible.

Now, your actual issue...  
Does it still happen if you uncheck `virtualized` ?

---

<div class="post-metadata">

**Author:** ![Alejandro\_Alaco](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/alejandro_alaco/32/59849_2.png) [@Alejandro\_Alaco](https://forum.inductiveautomation.com/u/Alejandro_Alaco)\
**Post date:** [June 12, 2025, 9:24am UTC](https://forum.inductiveautomation.com/t/script-transform-apply-to-whole-table-not-just-visible-part/107235/4 "2025-06-12T09:24:42Z")

</div>

Thanks @pascal.fragnoud

the thing is as follow

I have a data binding to a table with the last script transform like this to put all text on UTF-8 format:  
 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/7/2/72b542f8f4d454503c04dd9bd7645776180a9117.png)

![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/6/1/61c09aa1dbd812bfed6f610d810ecc255f877cfb.png)

```python
def transform(self, value, quality, timestamp):
	
	
	if value is None:
	    return value # No hacer nada si no hay datos
	
	try:
	    py_data = system.dataset.toPyDataSet(value)
	    headers = py_data.getColumnNames()
	    output_data = []
	
	    for row in py_data:
	        new_row = []
	        for col in headers:
	            val = row[col]
	            if isinstance(val, str):
	                try:
	                    val = val.encode('latin1').decode('utf-8')
	                except:
	                    pass
	            new_row.append(val)
	        output_data.append(new_row)
	
	    return system.dataset.toDataSet(headers, output_data)
	
	except Exception as e:
	    system.perspective.print("Transform error: " + str(e))
	    return value

```

Then when I open the page I see the table in good format:

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/8/5/858ef12c06e43f4e30dc56ab23e54162fec68233.png)

but when I navigate to other part of the table it doesn´t show UTF-8 format:

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/0/1/018b72008637d5970600946e61ef1ddb48f92319.png)

This happen even when I aply the format to the datasource bia script transform

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/9/7/973fb7e69be86172298ac78f0de14ad53294ebea.png)

---

<div class="post-metadata">

**Author:** ![pascal.fragnoud](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pascal.fragnoud/32/24728_2.png) [@pascal.fragnoud](https://forum.inductiveautomation.com/u/pascal.fragnoud)\
**Post date:** [June 12, 2025, 9:48am UTC](https://forum.inductiveautomation.com/t/script-transform-apply-to-whole-table-not-just-visible-part/107235/5 "2025-06-12T09:48:11Z")

</div>

> [@pascal.fragnoud](#):
>
> Does it still happen if you uncheck `virtualized` ?

Also, why do you have multiple script transforms chained ?  
You should probably be doing all your scripting in the same transform.  
If it's too big or too complicated, use library functions.

---

<div class="post-metadata">

**Author:** ![Alejandro\_Alaco](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/alejandro_alaco/32/59849_2.png) [@Alejandro\_Alaco](https://forum.inductiveautomation.com/u/Alejandro_Alaco)\
**Post date:** [June 12, 2025, 10:24am UTC](https://forum.inductiveautomation.com/t/script-transform-apply-to-whole-table-not-just-visible-part/107235/6 "2025-06-12T10:24:21Z")

</div>

Yes, I just tried with the virtualized unchecked and doesn´t work neither

I use multiple scripts sometimes when I have to modify something I did before, for me it makes the data transform more clear.

Maybe if I can cancel the pagination it could work.

---

<div class="post-metadata">

**Author:** ![vtran](https://avatars.discourse-cdn.com/v4/letter/v/779978/32.png) [@vtran](https://forum.inductiveautomation.com/u/vtran)\
**Post date:** [June 12, 2025, 11:33am UTC](https://forum.inductiveautomation.com/t/script-transform-apply-to-whole-table-not-just-visible-part/107235/7 "2025-06-12T11:33:48Z")

</div>

If you move your initial data binding and transform somewhere else, like `view.custom.data`, then bind your table `props.data` to it, would there still be the same issue?

---

<div class="post-metadata">

**Author:** ![Alejandro\_Alaco](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/alejandro_alaco/32/59849_2.png) [@Alejandro\_Alaco](https://forum.inductiveautomation.com/u/Alejandro_Alaco)\
**Post date:** [June 12, 2025, 11:40am UTC](https://forum.inductiveautomation.com/t/script-transform-apply-to-whole-table-not-just-visible-part/107235/8 "2025-06-12T11:40:45Z")

</div>

Yes, I tried to aply the script transform to a external custom.data property and have the same issue...a bit extrange

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/d/9/d9b854c4f22de5c539fea6bfcf87da1372c8d851.png)

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/d/d/ddadc6d5af40bd13b5a6c20cf44d439ce48e6647.png)

---

<div class="post-metadata">

**Author:** ![pascal.fragnoud](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pascal.fragnoud/32/24728_2.png) [@pascal.fragnoud](https://forum.inductiveautomation.com/u/pascal.fragnoud)\
**Post date:** [June 12, 2025, 11:55am UTC](https://forum.inductiveautomation.com/t/script-transform-apply-to-whole-table-not-just-visible-part/107235/9 "2025-06-12T11:55:27Z")

</div>

Is it formatted properly in the custom prop ?

---

<div class="post-metadata">

**Author:** ![Alejandro\_Alaco](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/alejandro_alaco/32/59849_2.png) [@Alejandro\_Alaco](https://forum.inductiveautomation.com/u/Alejandro_Alaco)\
**Post date:** [June 12, 2025, 12:04pm UTC](https://forum.inductiveautomation.com/t/script-transform-apply-to-whole-table-not-just-visible-part/107235/10 "2025-06-12T12:04:32Z")

</div>

Yes, in the custom prop everithing is formated properly  
 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/a/f/afe48a4018c348c690b6be7e0d57bec7fffcb419.png)

![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/f/9/f9b168b56fd34f5255bc413f317b111802e8b78c.png)

There is just the invalid key warning...

![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/9/e/9e34ec58dd862f283ffc4442d9f1dd81b71fec38.png)

I think is related to use **UTF-8 characters on named query with json return format**

but without json return format I can´t aply the Expression Structure Binding to fister with checkboxes

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/2/e/2e8602bd388de085279df615467f1ea248eef22c.png)
