# How to refresh a page with script

**URL:** <https://forum.inductiveautomation.com/t/how-to-refresh-a-page-with-script/56232>\
**Category:** Ignition\
**Tags:** perspective\
**Created:** [February 16, 2022, 10:13pm UTC](https://forum.inductiveautomation.com/t/how-to-refresh-a-page-with-script/56232 "2022-02-16T22:13:59Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Miguel\_Villasenor\_Es](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/miguel_villasenor_es/32/60416_2.png) [@Miguel\_Villasenor\_Es](https://forum.inductiveautomation.com/u/Miguel_Villasenor_Es)\
**Post date:** [February 16, 2022, 10:13pm UTC](https://forum.inductiveautomation.com/t/how-to-refresh-a-page-with-script/56232/1 "2022-02-16T22:13:59Z")

</div>

For simplicity. I have a button(A) whos text property value constantly changes. I accomplish this by clicking on button(B) who tells button(A) to update/refresh it’s text value property. What I need is the ability to have the button(A) text value change automatically. So when a person swipes there badge, it’ll register in the database and then a script runs and refreshes it. Here’s what I have.

1. In gateway event scripts, under tag change, I have a tag called splutchtag. Here is the script:  
sproc = system.db.createSProcCall(“splutchisnert”, “Lodestar”)  
sproc.registerInParam(‘BadgeNum’, system.db.INTEGER, badge)  
sproc.registerInParam(‘Area’, system.db.NVARCHAR, area)  
sproc.registerInParam(‘Line’, system.db.INTEGER, line)  
system.db.execSProcCall(sproc)  
name = self.session.props.auth.user.userName  
pid = self.page.props.pageId  
id =self.session.props.id  
logger = system.util.getLogger(“myLogger”)  
logger.info(name +"Session ID: "+id + " Page ID: "+pid)  
system.perspective.refresh(id,pid)

2. Someone badges in, a storedprocedure is called to placed said person in the database. I then try and use a system.perspective.rerfresh(pageid,sessionid). Nothing happens. I’ll get in a error in the logs. How do I refresh the page, or have the values on the button change when the tagchange script runs?

---

<div class="post-metadata">

**Author:** ![lrose](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/lrose/32/62724_2.png) [@lrose](https://forum.inductiveautomation.com/u/lrose)\
**Post date:** [February 16, 2022, 10:50pm UTC](https://forum.inductiveautomation.com/t/how-to-refresh-a-page-with-script/56232/2 "2022-02-16T22:50:26Z")

</div>

Gateway tag change events do not have access to Session properties, they occur outside of sessions. For instance, there can be no sessions open and tag change events will still occur.

Are you trying to use authentication outside of an IdP?

Consider using a custom session property in conjunction with a change event to execute your script in the session.

---

<div class="post-metadata">

**Author:** ![Miguel\_Villasenor\_Es](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/miguel_villasenor_es/32/60416_2.png) [@Miguel\_Villasenor\_Es](https://forum.inductiveautomation.com/u/Miguel_Villasenor_Es)\
**Post date:** [February 16, 2022, 10:52pm UTC](https://forum.inductiveautomation.com/t/how-to-refresh-a-page-with-script/56232/3 "2022-02-16T22:52:16Z")

</div>

No, I’m not trying to authenticate.  
Okay, so the gateway can access custom properties? And, these properties are what I can use to leverage the refresh?

---

<div class="post-metadata">

**Author:** ![Transistor](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/transistor/32/3380_2.png) [@Transistor](https://forum.inductiveautomation.com/u/Transistor)\
**Post date:** [February 16, 2022, 11:06pm UTC](https://forum.inductiveautomation.com/t/how-to-refresh-a-page-with-script/56232/4 "2022-02-16T23:06:14Z")

</div>

Try this:

1. Creating a memory tag, _ **myAppButtonA** _ in a tag folder named for your project.
2. Have your gateway script update the tag value.
3. Bind your button’s `props.text` to the memory tag.

The plan doesn’t sound like a great idea. If there’s a second copy of the application running then they will both update as they’re both watching the same memory tag.

* * *

_Tip: Use the `</>` code formatting button when posting code on the forum._

---

<div class="post-metadata">

**Author:** ![Miguel\_Villasenor\_Es](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/miguel_villasenor_es/32/60416_2.png) [@Miguel\_Villasenor\_Es](https://forum.inductiveautomation.com/u/Miguel_Villasenor_Es)\
**Post date:** [February 17, 2022, 12:06am UTC](https://forum.inductiveautomation.com/t/how-to-refresh-a-page-with-script/56232/5 "2022-02-17T00:06:33Z")

</div>

I am definitely going to have to try this! One problem I also had was that I placed that same code in a button and It would not refresh the page for me… It won’t give me errors.

---

<div class="post-metadata">

**Author:** ![lrose](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/lrose/32/62724_2.png) [@lrose](https://forum.inductiveautomation.com/u/lrose)\
**Post date:** [February 17, 2022, 2:45pm UTC](https://forum.inductiveautomation.com/t/how-to-refresh-a-page-with-script/56232/6 "2022-02-17T14:45:12Z")

</div>

> [@Miguel\_Villasenor\_Es](#):
>
> Okay, so the gateway can access custom properties?

The gateway **can't** access session properties, or any properties from a perspective session,page,view, or component.

You can use `sysetm.perspective.sendMessage()` in conjunction with a message handler to run your script and keep it specific to a session.
