# Typecasting Issue with Script Transform on Custom View Property

**URL:** <https://forum.inductiveautomation.com/t/typecasting-issue-with-script-transform-on-custom-view-property/52424>\
**Category:** Ignition\
**Tags:** ignition81, perspective\
**Created:** [October 27, 2021, 9:11pm UTC](https://forum.inductiveautomation.com/t/typecasting-issue-with-script-transform-on-custom-view-property/52424 "2021-10-27T21:11:53Z")\
**Posts on this page:** 14\
**Page:** 1

<div class="post-metadata">

**Author:** ![dominicfabiilli](https://avatars.discourse-cdn.com/v4/letter/d/c6cbf5/32.png) [@dominicfabiilli](https://forum.inductiveautomation.com/u/dominicfabiilli)\
**Post date:** [October 27, 2021, 9:11pm UTC](https://forum.inductiveautomation.com/t/typecasting-issue-with-script-transform-on-custom-view-property/52424/1 "2021-10-27T21:11:53Z")

</div>

I have a Perspective view with a custom property, type dataset.  
I bound this to a dataset tag and added a script transform to pick out the rows I need.  
The view populates correctly in the Designer, but not in a running session.

( I found a similar post here but it says this issue was resolved.  
[[Bug-1083]Perspective script not fully executing in client but does in Designer - #7 by nminchin](https://forum.inductiveautomation.com/t/bug-1083-perspective-script-not-fully-executing-in-client-but-does-in-designer/43451/7) )

PROBLEM:  
The image shows my browser console output for my datatype in my script transform.  
It seems that the parameter enters the code as an INT, but eventually turns into a DATASET.  
Unfortunately, the INT is used when proceeding through the script and causes an exception.

![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/1/8/18eb6297b7b3863245ac186af18037b6f971d9b0.png)

---

<div class="post-metadata">

**Author:** ![victordcq](https://avatars.discourse-cdn.com/v4/letter/v/f6c823/32.png) [@victordcq](https://forum.inductiveautomation.com/u/victordcq)\
**Post date:** [October 28, 2021, 6:47am UTC](https://forum.inductiveautomation.com/t/typecasting-issue-with-script-transform-on-custom-view-property/52424/2 "2021-10-28T06:47:43Z")

</div>

are you using the version that it was fixed in?  
could you share some code?

---

<div class="post-metadata">

**Author:** ![dominicfabiilli](https://avatars.discourse-cdn.com/v4/letter/d/c6cbf5/32.png) [@dominicfabiilli](https://forum.inductiveautomation.com/u/dominicfabiilli)\
**Post date:** [October 28, 2021, 12:23pm UTC](https://forum.inductiveautomation.com/t/typecasting-issue-with-script-transform-on-custom-view-property/52424/3 "2021-10-28T12:23:16Z")

</div>

I am using Ignition 8.1.9.  
I am seeing this error: “AttributeError: ‘int’ object has no attribute ‘getColumnCount’”

This is the only line where I print a Perspective message:

```auto
system.perspective.print('TESTING --- type: %s' %str(type(dataRaw)))
iColumnCount = dataRaw.getColumnCount()

```

---

<div class="post-metadata">

**Author:** ![victordcq](https://avatars.discourse-cdn.com/v4/letter/v/f6c823/32.png) [@victordcq](https://forum.inductiveautomation.com/u/victordcq)\
**Post date:** [October 28, 2021, 2:04pm UTC](https://forum.inductiveautomation.com/t/typecasting-issue-with-script-transform-on-custom-view-property/52424/4 "2021-10-28T14:04:38Z")

</div>

Yeah im not much with two lines… Could you show every line that uses dataRaw xD

---

<div class="post-metadata">

**Author:** ![cmallonee](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/cmallonee/32/6416_2.png) [@cmallonee](https://forum.inductiveautomation.com/u/cmallonee)\
**Post date:** [October 28, 2021, 4:08pm UTC](https://forum.inductiveautomation.com/t/typecasting-issue-with-script-transform-on-custom-view-property/52424/5 "2021-10-28T16:08:21Z")

</div>

Could you please share the code _preceding_ the print statement you’ve provided?

---

<div class="post-metadata">

**Author:** ![dominicfabiilli](https://avatars.discourse-cdn.com/v4/letter/d/c6cbf5/32.png) [@dominicfabiilli](https://forum.inductiveautomation.com/u/dominicfabiilli)\
**Post date:** [October 28, 2021, 5:11pm UTC](https://forum.inductiveautomation.com/t/typecasting-issue-with-script-transform-on-custom-view-property/52424/6 "2021-10-28T17:11:35Z")

</div>

I pass in a dataset-tag from an expression (which becomes “value”).  
I simplified my code to what’s shown below and I still get a type INT before a Dataset.  
I also removed all other bindings and scripts from the View.

Another question, do you know why this would be executing multiple times?

```auto
dataRaw = value
system.perspective.print('TESTING --- type: %s' %str(type(dataRaw)))
iColumnCount = dataRaw.getColumnCount()

```

---

<div class="post-metadata">

**Author:** ![cmallonee](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/cmallonee/32/6416_2.png) [@cmallonee](https://forum.inductiveautomation.com/u/cmallonee)\
**Post date:** [October 28, 2021, 5:15pm UTC](https://forum.inductiveautomation.com/t/typecasting-issue-with-script-transform-on-custom-view-property/52424/7 "2021-10-28T17:15:56Z")

</div>

The binding and transform will execute when the binding “starts up” (when the View/component mounts) and then again whenever the tag changes.

Is there any chance you could export the View and supply the json file here?

---

<div class="post-metadata">

**Author:** ![dominicfabiilli](https://avatars.discourse-cdn.com/v4/letter/d/c6cbf5/32.png) [@dominicfabiilli](https://forum.inductiveautomation.com/u/dominicfabiilli)\
**Post date:** [October 28, 2021, 6:24pm UTC](https://forum.inductiveautomation.com/t/typecasting-issue-with-script-transform-on-custom-view-property/52424/8 "2021-10-28T18:24:29Z")

</div>

Well, I was able to simplify the view for export and put in some extra print statements.  
As a result, it looks like I can get a column count eventually if I check the datatype before executing.

![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/4/7/47881d3c7eba7eb0024db068fa26f74d638ea8b0.png)

---

<div class="post-metadata">

**Author:** ![dominicfabiilli](https://avatars.discourse-cdn.com/v4/letter/d/c6cbf5/32.png) [@dominicfabiilli](https://forum.inductiveautomation.com/u/dominicfabiilli)\
**Post date:** [October 28, 2021, 6:25pm UTC](https://forum.inductiveautomation.com/t/typecasting-issue-with-script-transform-on-custom-view-property/52424/9 "2021-10-28T18:25:54Z")

</div>

But I have not attached anything, because I may have solved the problem by being more thorough.  
Thanks for your help guys.

---

<div class="post-metadata">

**Author:** ![cmallonee](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/cmallonee/32/6416_2.png) [@cmallonee](https://forum.inductiveautomation.com/u/cmallonee)\
**Post date:** [October 28, 2021, 6:40pm UTC](https://forum.inductiveautomation.com/t/typecasting-issue-with-script-transform-on-custom-view-property/52424/10 "2021-10-28T18:40:52Z")

</div>

Putting in extra handling is just going to mask the fact that you’re getting an unexpected value. It’s been my experience than until you understand how/why that value is entering your script that you are going to encounter this again somewhere else.

---

<div class="post-metadata">

**Author:** ![victordcq](https://avatars.discourse-cdn.com/v4/letter/v/f6c823/32.png) [@victordcq](https://forum.inductiveautomation.com/u/victordcq)\
**Post date:** [October 29, 2021, 11:25am UTC](https://forum.inductiveautomation.com/t/typecasting-issue-with-script-transform-on-custom-view-property/52424/11 "2021-10-29T11:25:57Z")

</div>

Yea just catching this isnt really a good idea.  
I think its either your dataset or your tag that is failing on load for some reason…

You will have to starts showing some more than just console prints tho if you want more help xd  
show us the dataset tag, how it gets it values and the expression you used

---

<div class="post-metadata">

**Author:** ![dominicfabiilli](https://avatars.discourse-cdn.com/v4/letter/d/c6cbf5/32.png) [@dominicfabiilli](https://forum.inductiveautomation.com/u/dominicfabiilli)\
**Post date:** [November 8, 2021, 4:28pm UTC](https://forum.inductiveautomation.com/t/typecasting-issue-with-script-transform-on-custom-view-property/52424/12 "2021-11-08T16:28:05Z")

</div>

I think I have narrowed down the problem. It seems that the View Params and View Custom properties load in an unexpected order. Here is my process to load data into my page:

- I navigate to the page url with a parameter passed in (i.e. parameter passed in as “/page/:StationID”)
- This parameter is used in an expression binding to determine which tagname to read in a Custom property (i.e. property of “StationName” is bound to “StationID”)

In the session, my table gets an overlay with a BAD tagpath:  
‘[TP]Folder…/ERROR/…’ not found.

The “ERROR” string value comes from the failed expression which is “case(1, ‘name1’, … , ‘ERROR’)”

Any thoughts?

---

<div class="post-metadata">

**Author:** ![cmallonee](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/cmallonee/32/6416_2.png) [@cmallonee](https://forum.inductiveautomation.com/u/cmallonee)\
**Post date:** [November 8, 2021, 7:48pm UTC](https://forum.inductiveautomation.com/t/typecasting-issue-with-script-transform-on-custom-view-property/52424/13 "2021-11-08T19:48:18Z")

</div>

That expression binding is always going to fault because URL params will ALWAYS be string values, and you’re only supplying one unchanging value of `1`. Try something like this instead:

```auto
case({self.view.params.StationID}, "1", "name1", … , "ERROR")

```

Although if you follow a naming pattern, you could always just do

```auto
"name" + {self.view.params.StationID}

```

---

<div class="post-metadata">

**Author:** ![dominicfabiilli](https://avatars.discourse-cdn.com/v4/letter/d/c6cbf5/32.png) [@dominicfabiilli](https://forum.inductiveautomation.com/u/dominicfabiilli)\
**Post date:** [November 8, 2021, 8:56pm UTC](https://forum.inductiveautomation.com/t/typecasting-issue-with-script-transform-on-custom-view-property/52424/14 "2021-11-08T20:56:27Z")

</div>

That fixed it thanks!
