# Change Script on View Params

**URL:** <https://forum.inductiveautomation.com/t/change-script-on-view-params/63529>\
**Category:** Ignition\
**Tags:** ignition81, perspective\
**Created:** [August 27, 2022, 3:19pm UTC](https://forum.inductiveautomation.com/t/change-script-on-view-params/63529 "2022-08-27T15:19:40Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![cme75](https://avatars.discourse-cdn.com/v4/letter/c/7bcc69/32.png) [@cme75](https://forum.inductiveautomation.com/u/cme75)\
**Post date:** [August 27, 2022, 3:19pm UTC](https://forum.inductiveautomation.com/t/change-script-on-view-params/63529/1 "2022-08-27T15:19:40Z")

</div>

Hello,

I am facing a strange behavior or maybe it is a design problem/misunderstanding how parameters should be used. I am opening a dock view with an ID parameter from the main view. This ID parameter has a change script that should load the details for that particular ID or if it -1 it should create a blank/new record. Further, when the dock is opened the change script loads some data for dropdown fields.

I realized that when I open a dock with a specific ID, then close it and open the same one again, it will not execute the change script again since the value did not change. Even after reloading the entire page, it does not execute the change script again. It seems that the value is retained in the memory

So, what would be the best way to open a dock view with an ID and load additional data. I already added another parameter which always contains a random value and added the change value script to it but I don’t like it because I am not sure whether it is guaranteed that the ID field is already filled with the new value when the change script is executing.

Also, what would be the best way to deal with the initial values in the parameters that were in there from the designer. Can those somehow be initialized. I tried to use the startup script but it does not seem to execute when the docked view is opened

Thanks, Carsten

---

<div class="post-metadata">

**Author:** ![nminchin](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/nminchin/32/6911_2.png) [@nminchin](https://forum.inductiveautomation.com/u/nminchin)\
**Post date:** [August 28, 2022, 12:23pm UTC](https://forum.inductiveautomation.com/t/change-script-on-view-params/63529/2 "2022-08-28T12:23:47Z")

</div>

Docks are never closed as such, they are simply pushed out of the visible viewport, hence they only trigger any on opened scripts once. You should be able to pass parameters to the dock though to set your ID

---

<div class="post-metadata">

**Author:** ![cme75](https://avatars.discourse-cdn.com/v4/letter/c/7bcc69/32.png) [@cme75](https://forum.inductiveautomation.com/u/cme75)\
**Post date:** [August 28, 2022, 12:54pm UTC](https://forum.inductiveautomation.com/t/change-script-on-view-params/63529/3 "2022-08-28T12:54:38Z")

</div>

I am passing the ID as a parameter. The problem is if the ID value does not change the change value script does not get executed. I need to be able to execute it every single time. Is there a different event or a complete different way that i could use in these cases?

---

<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:** [August 28, 2022, 1:43pm UTC](https://forum.inductiveautomation.com/t/change-script-on-view-params/63529/4 "2022-08-28T13:43:40Z")

</div>

Don’t use a parameter. Use a custom property, and send a message to the dock to set it.

---

<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:** [August 28, 2022, 6:46pm UTC](https://forum.inductiveautomation.com/t/change-script-on-view-params/63529/5 "2022-08-28T18:46:22Z")

</div>

I agree that sending a message to force an update is probably the best idea.

```auto
# order matters here because you want the dock to be in place and available to hear the message
system.perspective.openDock("DOCK_ID", params={"some_param": 1})
system.perspective.sendMessage("UPDATE_DOCK_BINDINGS", scope="page")

```

Then the relevant components of the Docked View should have listeners configured for an `UPDATE_DOCK_BINDINGS` Message Handler which does the following:

```auto
self.refreshBinding("props.<some_prop>")

```

---

<div class="post-metadata">

**Author:** ![cme75](https://avatars.discourse-cdn.com/v4/letter/c/7bcc69/32.png) [@cme75](https://forum.inductiveautomation.com/u/cme75)\
**Post date:** [August 29, 2022, 2:39pm UTC](https://forum.inductiveautomation.com/t/change-script-on-view-params/63529/6 "2022-08-29T14:39:50Z")

</div>

Thanks everyone, it works smoothly 🙂

---

<div class="post-metadata">

**Author:** ![nminchin](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/nminchin/32/6911_2.png) [@nminchin](https://forum.inductiveautomation.com/u/nminchin)\
**Post date:** [August 30, 2022, 10:54pm UTC](https://forum.inductiveautomation.com/t/change-script-on-view-params/63529/7 "2022-08-30T22:54:45Z")

</div>

@pturmel @cmallonee

Remind me again, why can’t you just pass the new param value in via `openDock`? Why do you mention using `refreshBinding` as well? I remember something about this but it’s been a while since I’ve touched docked Views…

---

<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:** [August 31, 2022, 1:54am UTC](https://forum.inductiveautomation.com/t/change-script-on-view-params/63529/8 "2022-08-31T01:54:00Z")

</div>

The concern here is that the value of the param is not changing, and therefore the change scripts are not executing as the docked view opens/closes.

> [@cme75](#):
>
> The problem is if the ID value does not change the change value script

---

<div class="post-metadata">

**Author:** ![nminchin](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/nminchin/32/6911_2.png) [@nminchin](https://forum.inductiveautomation.com/u/nminchin)\
**Post date:** [August 31, 2022, 1:55am UTC](https://forum.inductiveautomation.com/t/change-script-on-view-params/63529/9 "2022-08-31T01:55:47Z")

</div>

OH, I completely missed that 🙂 That makes sense then

---

<div class="post-metadata">

**Author:** ![liam1](https://avatars.discourse-cdn.com/v4/letter/l/e68b1a/32.png) [@liam1](https://forum.inductiveautomation.com/u/liam1)\
**Post date:** [September 7, 2022, 9:55am UTC](https://forum.inductiveautomation.com/t/change-script-on-view-params/63529/10 "2022-09-07T09:55:05Z")

</div>

I’m experiencing the same issue, the parameter is not updating on the view when using the `system.perspective.openDock` function after the first open and close.

The parameter values being passed to the `system.perspective.openDock` are different but the parameter values on the view are not updating.

I’m using the fix suggested by pturmal , `system.perspective.sendMessage()` to send the data to the view.
