# Custom script function dataset parameter

**URL:** <https://forum.inductiveautomation.com/t/custom-script-function-dataset-parameter/72349>\
**Category:** Ignition\
**Tags:** ignition81, perspective\
**Created:** [April 12, 2023, 10:34am UTC](https://forum.inductiveautomation.com/t/custom-script-function-dataset-parameter/72349 "2023-04-12T10:34:52Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Cameronin](https://avatars.discourse-cdn.com/v4/letter/c/9fc29f/32.png) [@Cameronin](https://forum.inductiveautomation.com/u/Cameronin)\
**Post date:** [April 12, 2023, 10:34am UTC](https://forum.inductiveautomation.com/t/custom-script-function-dataset-parameter/72349/1 "2023-04-12T10:34:53Z")

</div>

Hello!  
I'm trying to get a project script function to take a dataset as a parameter.  
I've set up the function in the project script library as "def myFunction(dataset):", and I'm trying to call it from a binding on a custom property.  
The binding value is a datset.  
It shows as type BasicDataset when I check eith "return type(value)".

When I do a script transform to call the function:

```auto
def transform(self,value,quality,timestamp):
      myResult = myScript.Scripts().myFunction(dataset = value)

```

I get the error:  
TypeError: myFunction() got multiple values for key word argument 'dataset'

I don't know if this just isn't a thing I can do; or if I need to change the way I'm passing the dataset; or convert it somehow; or something else.

A quick search through the forum suggests I might need an import of something, but I don't really understand it.

Any pointers gratefully received!  
Thanks

---

<div class="post-metadata">

**Author:** ![JordanCClark](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/jordancclark/32/83362_2.png) [@JordanCClark](https://forum.inductiveautomation.com/u/JordanCClark)\
**Post date:** [April 12, 2023, 11:13am UTC](https://forum.inductiveautomation.com/t/custom-script-function-dataset-parameter/72349/2 "2023-04-12T11:13:12Z")

</div>

> [@Cameronin](#):
>
> TypeError: myFunction() got multiple values for key word argument 'dataset'

Have you tried it without the assignation?

```python
myResult = myScript.Scripts().myFunction(value)

```

---

<div class="post-metadata">

**Author:** ![Cameronin](https://avatars.discourse-cdn.com/v4/letter/c/9fc29f/32.png) [@Cameronin](https://forum.inductiveautomation.com/u/Cameronin)\
**Post date:** [April 12, 2023, 11:17am UTC](https://forum.inductiveautomation.com/t/custom-script-function-dataset-parameter/72349/3 "2023-04-12T11:17:30Z")

</div>

I have, yup.  
It gives:  
TypeError: myFunction() takes eactly 1 argument (2 given)

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [April 12, 2023, 12:37pm UTC](https://forum.inductiveautomation.com/t/custom-script-function-dataset-parameter/72349/4 "2023-04-12T12:37:32Z")

</div>

> [@Cameronin](#):
>
> `myScript.Scripts().myFunction`

Why does `Scripts()` have parentheses?

---

<div class="post-metadata">

**Author:** ![Cameronin](https://avatars.discourse-cdn.com/v4/letter/c/9fc29f/32.png) [@Cameronin](https://forum.inductiveautomation.com/u/Cameronin)\
**Post date:** [April 12, 2023, 3:40pm UTC](https://forum.inductiveautomation.com/t/custom-script-function-dataset-parameter/72349/5 "2023-04-12T15:40:09Z")

</div>

@pturmel more accurately I suppose it's myScript.myClass().myFunction

I've popped the function into a project script I've inherited that has a class definition.  
It could be doing all sorts of things I don't understand.  
The brackets are there because that's the syntax elsewhere in the project for calling functions from that script.  
I don't actually know if they're needed!

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [April 12, 2023, 3:44pm UTC](https://forum.inductiveautomation.com/t/custom-script-function-dataset-parameter/72349/6 "2023-04-12T15:44:13Z")

</div>

Well, in that case, you would be calling a method, not a function, and methods need `self` as their first argument (in the definition, not where called).

Consider sharing the whole script.

---

<div class="post-metadata">

**Author:** ![Cameronin](https://avatars.discourse-cdn.com/v4/letter/c/9fc29f/32.png) [@Cameronin](https://forum.inductiveautomation.com/u/Cameronin)\
**Post date:** [April 12, 2023, 3:54pm UTC](https://forum.inductiveautomation.com/t/custom-script-function-dataset-parameter/72349/7 "2023-04-12T15:54:05Z")

</div>

@pturmel  
I have taken the function outside the class, and just made the call myScript.myFunction(dataset).  
It is now working! Huzzah!

Thank you for the data point on methods as opposed to functions, it should make life easier and less trial-and-error based 😃
