IP based autologin -Vision

Hi,
I would like to have the below functionality-

When a person from M-01 area launches the application, machineboard for this machine should display directly with 6 menus above. he should not be able to navigate to other icons.

Similarly when a person from M-02 launches, same applies and he will not be able to view other machine details.

This user login information can be distinguished with their login IP. for eg :if 172.16.10.90 is for M-01, 172.16.10.91 is for M-02.

Client event script Used:

ipAddress = system.tag.read("[System]Client/Network/IPAddress").value 
query = """SELECT Process as Process , MachineID as MachineID FROM cdcms.tbl_ip_details where IP_Address=?""" 
userInfo = system.db.runPrepQuery(query,[ipAddress])[0]
window1="Main Windows/Machine/Machine Board"
window2="Main Windows/Machine/Machine Board-East Dock"
window3="Main Windows/Machine/Machine Board-West Dock"
system.nav.openWindow("window1",{"Process":Process},{"MachineID":MachineID} )
system.nav.openWindow("window2",{"Process":Process},{"MachineNo":MachineID} )
system.nav.openWindow("window3")

image
I am getting below error:

In your code sample, I don't see a definition for Process or MachineID.

How to assign the results from below query to a variable.

query = """SELECT Process as Process , MachineID as MachineID FROM cdcms.tbl_ip_details where IP_Address=?""" 

Remove the """ from the query. runPrepQuery will pass the data as a string.

query = "SELECT Process, MachineID 
         FROM cdcms.tbl_ip_details WHERE IP_Address = ?"
userInfo = system.db.runPrepQuery(query, [ipAddress])[0]

Process AS Process, etc. is redundant so I've removed the AS parts.

Still i am getting the same error

You will need to create variables and assign the values from userInfo to them.
I'm not where I can test code, but it should look something like this:

Process = userInfo.getValueAt(0,"Process")
MachineID = userInfo.getValueAt(0,"MachineID")
1 Like

The user manual says the syntax is
system.nav.openWindow(path, [params])

Try,

system.nav.openWindow("window1",
    {"Process": Process, "MachineID": MachineID})

Mind your spacing in your code. Standard is no space before punctuation and one space after punctuation. It will improve legibility.

1 Like