# Calling Extension function of a Vision component

**URL:** <https://forum.inductiveautomation.com/t/calling-extension-function-of-a-vision-component/61009>\
**Category:** Ignition\
**Tags:** ignition81, vision\
**Created:** [June 21, 2022, 1:55pm UTC](https://forum.inductiveautomation.com/t/calling-extension-function-of-a-vision-component/61009 "2022-06-21T13:55:36Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![sppatil](https://avatars.discourse-cdn.com/v4/letter/s/c68b51/32.png) [@sppatil](https://forum.inductiveautomation.com/u/sppatil)\
**Post date:** [June 21, 2022, 1:55pm UTC](https://forum.inductiveautomation.com/t/calling-extension-function-of-a-vision-component/61009/1 "2022-06-21T13:55:36Z")

</div>

I am using Ignition v8.1.17 and Sepasoft SPC module (v3.81.5 SP1). I want to filter sample definition based on the selection of the Location. Sample Definition Manager component has a `filterSampleDefinition` extension function which returns the filtered list but it runs only when the window containing it is opened. I want to provide the option to filter list on other event like button click, dropdown option selection etc.  
Is there any way to _refresh_ component to call this extension function? This method could potentially be used for other components as well.

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

---

<div class="post-metadata">

**Author:** ![bkarabinchak.psi](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/bkarabinchak.psi/32/83567_2.png) [@bkarabinchak.psi](https://forum.inductiveautomation.com/u/bkarabinchak.psi)\
**Post date:** [June 21, 2022, 2:02pm UTC](https://forum.inductiveautomation.com/t/calling-extension-function-of-a-vision-component/61009/2 "2022-06-21T14:02:01Z")

</div>

If you need to write something that will be called in multiple spots or components, write your script in your project scripting library, and then call it from the appropriate extension functions. That’s for the code duplication part/being able to use it in other components.

Not sure what you mean regarding refreshing the component.

---

<div class="post-metadata">

**Author:** ![sppatil](https://avatars.discourse-cdn.com/v4/letter/s/c68b51/32.png) [@sppatil](https://forum.inductiveautomation.com/u/sppatil)\
**Post date:** [June 21, 2022, 2:25pm UTC](https://forum.inductiveautomation.com/t/calling-extension-function-of-a-vision-component/61009/3 "2022-06-21T14:25:26Z")

</div>

By refresh I mean making the component to call the extension function similar to way it does when window containing the component is opened. I am not sure if the arguments (their value) passed to the extension function by component can be obtained/created outside of the component. It might be possible to use some other functions and create these arguments but there is no property on the component which I can write the resultant filtered list to.  
Instead if it is possible to trigger the call to the extension function (or rather making component to call extension function as one of the arguments is component itself), it would make it easier.

---

<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:** [June 21, 2022, 6:02pm UTC](https://forum.inductiveautomation.com/t/calling-extension-function-of-a-vision-component/61009/4 "2022-06-21T18:02:54Z")

</div>

You can try [system.db.refresh()](https://docs.inductiveautomation.com/display/DOC81/system.db.refresh), but as this is a Sepasoft component, you may have [better luck asking them](https://www.sepasoft.com/support/) if if that doesn’t work.

---

<div class="post-metadata">

**Author:** ![sppatil](https://avatars.discourse-cdn.com/v4/letter/s/c68b51/32.png) [@sppatil](https://forum.inductiveautomation.com/u/sppatil)\
**Post date:** [June 22, 2022, 9:56am UTC](https://forum.inductiveautomation.com/t/calling-extension-function-of-a-vision-component/61009/5 "2022-06-22T09:56:57Z")

</div>

I could not use `system.db.refresh()` since it requires the property name as one of the arguments and works for properties with DB bindings. For above component no property name is available that can be used for the extension function.

Since many Vision components have extension functions I was thinking there might be some way to trigger the extension function which will be applicable to any such component.

From [javadocs](https://github.com/inductiveautomation/ignition-sdk-examples/wiki/Javadocs-&-Notable-API-Changes), I found that there is `startupComponent` method that reloads the component making it to call the extension function. I tested below code on button click and it is working for above mentioned component. I think it should work for other Ignition/Sepasoft components having extension functions.

> comp = event.source.parent.getComponent('SPC Sample Definition Manager')  
> appContext = comp.getAppContext()  
> comp.startupComponent(appContext)

I have enabled only one extension function out of 3 available functions.

---

<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:** [June 22, 2022, 12:00pm UTC](https://forum.inductiveautomation.com/t/calling-extension-function-of-a-vision-component/61009/6 "2022-06-22T12:00:18Z")

</div>

> [@sppatil](#):
>
> and works for properties with DB bindings.

No, it works for any property binding. Most components will refresh if any bindable property changes. Consider adding a custom property that you can toggle just to see if that will trigger it.

---

<div class="post-metadata">

**Author:** ![sppatil](https://avatars.discourse-cdn.com/v4/letter/s/c68b51/32.png) [@sppatil](https://forum.inductiveautomation.com/u/sppatil)\
**Post date:** [June 22, 2022, 12:53pm UTC](https://forum.inductiveautomation.com/t/calling-extension-function-of-a-vision-component/61009/7 "2022-06-22T12:53:44Z")

</div>

You are correct. In fact it is mentioned in the manual as well. But from the code snippet which shows the example of data property of Table component being updated, I jumped to conclusion too quickly 😬

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

I created a custom property on component which is bound to location selector as I want to filter definitions list based on this selection. Value change in this property doesn’t seem to be calling extension function as there is no change in the sample definition list.

I also tried calling refresh function on change of this property’s value. It’s printing the value of property but the print statement in the extension function is not printing anything.

```auto
if event.propertyName == 'SelectedLocation':
     print event.source.SelectedLocation
     system.db.refresh(event.source, 'SelectedLocation')

```

---

<div class="post-metadata">

**Author:** ![code\_skin](https://avatars.discourse-cdn.com/v4/letter/c/43a26b/32.png) [@code\_skin](https://forum.inductiveautomation.com/u/code_skin)\
**Post date:** [June 22, 2022, 1:01pm UTC](https://forum.inductiveautomation.com/t/calling-extension-function-of-a-vision-component/61009/8 "2022-06-22T13:01:49Z")

</div>

I never knew this! Sometimes testing is better than RTFM.
