How to refresh a page with script

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?

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.

1 Like

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?

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.

1 Like

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.

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.

1 Like