FactoryTalk SE Current User into PLC Tag

threetrey

Member
Join Date
Feb 2020
Location
USA
Posts
18
Hello everyone, hoping someone here has experience with doing something like this.
I am wanting to transfer a string of the currently logged in user into a tag in the PLC.
I've been trying to do it using a derived tag with the CurrentUserName()function, but so far all I've been able to get to show in the PLC tag is just "CurrentUserName()" as text, rather than the actual logged in user.
I'm guessing i'm not using the function correctly in the expression window. Does anybody have an idea what I'm doing wrong, or know of any others ways to be able to accomplish this?
 
The CurrentUserName() function doesn't appear to be available to be used as part of the expression within derived tags.

I suspect that is probably because derived tags runs at the server level whereas the CurrentUserName is at the client level. Many client level commands are prevented from being used in derived tags (and events).

It can be done using VBA and it is pretty easy to do even if you aren't handy with VBA.

Step #1
Open a display. Create a string display object configured to show CurrentUserName(). Note the name of the object. It is usually called StringDisplay1 and then that number increments for each string display object on that screen. In the Common tab of the Properties window you can uncheck Visible if you don't want to see this on the display.

Step #2
Create a numeric input object. Assign the tag you wish to write the username to. Note the name of the object. In the Common tab of the Properties window you can also uncheck Visible if you don't want to see this on the display. We will use VBA code to write the value from the display object to our input object.

Step #3
Right click on each object, select Property Panel and in that panel where it says Expose to VBA, set that to VBA Control. Make sure you do this for both objects.

Step #4
Right-click on the String Display object and select VBA Code. In the Change field enter the following

StringInput1.Value = StringDisplay1.Value
StringInput1.Download

In my example, my string display object was named StringDisplay1 and my String Input object was named StringInput1. Change these to match the names of your objects.

Be aware that if you have multiple clients, they would be overwriting each other with this information. Since this will only execute when this display is open, you will want to copy these items to other displays.

OG

Username.jpg
 
Last edited:
I revised my comments a little but it was too late to edit my previous post. Here is the revised comment minus the picture.

The CurrentUserName() function doesn't appear to be available to be used as part of the expression within derived tags. I suspect that is probably because derived tags runs at the server level whereas the CurrentUserName is at the client level. Many client level commands are prevented from being used in derived tags (and events). The good news is that it can be done using VBA, and it is pretty easy to do even if you aren't handy with VBA.

Step #1
Open a display. Create a string display object configured to show CurrentUserName(). Note the name of the object. It is usually called StringDisplay1 and then that number increments for each string display object on that screen. In the Common tab of the Properties window you can uncheck Visible if you don't want to see this on the running display. You will still see it in the development environment.

Step #2
Create a numeric input object. Assign the tag you wish to write the username to. Note the name of the object. You can also uncheck Visible if you don't want to see this on the display. We will use VBA code to write the value from the display object to our input object.

Step #3
Right click on one of the objects, select Property Panel, and in that panel where it says "Expose to VBA", set that to VBA Control. Do this for both the display and input objects.

Step #4
Right-click on the String Display object and select VBA Code. In the Change field, enter the following

StringInput1.Value = StringDisplay1.Value
StringInput1.Download

In my example, my string display object was named StringDisplay1 and my String Input object was named StringInput1. Change these to match the names of your objects.

Be aware that if you have multiple clients, they would be overwriting each other with this information. If you have five clients all connected to the same system, they would each be writing the user name to that same tag. So that gets a little trickier. I'm assuming you'll have just the one client at a time.

Since this will only execute when this display is open, you will want to copy these items to any display where a user can log in or log out. Or if you have a window that stays open all the time, that is a good place to put this.

OG
 
OG thanks for this, I believe this should do what I'm looking for.
I'm working through trying to fix some ActiveX issues on the display I'm trying to set it up on, so haven't gotten to test it yet. But this makes sense and looks like it should work to me.


I do actually have multiple clients on this system. Is it possible to pull the username from just one or two specific clients?


Janner, have you been able to do this before with the system/User tag? I was thinking about trying that, but from what I've read it looked like that tag is now obsolete?
 
Janner, have you been able to do this before with the system/User tag? I was thinking about trying that, but from what I've read it looked like that tag is now obsolete?

It is effectively obsolete. System\User is there for compatibility importing older RSView32 applications but it does not really work anymore in View SE. At least it doesn't work the way it did in RSView. It does work fine in View ME still.

SE is a Client/Server system. System\User would show the user name for who is logged in at the server. It cannot show you the individual user names at the client.

OG
 
I do actually have multiple clients on this system. Is it possible to pull the username from just one or two specific clients?

This gets trickier. It would probably require us to give each client a unique startup macro that would use a placeholder to pass a unique number to identify the client. Then use that unique number to write the user name to a tag specifically for that client. You would have to create a tag in the PLC for each client that you want to know who is logged in. Otherwise the clients would all by writing to the same location and overwriting each other.

I have not done this before. But it should work.

OG
 
For these kind of systems I usually make a UDT called HMI_Type. One of the fields is CurrentUser of type string.

I then use that type for each HMI location like, HMI_Filler, HMI_Seamer etc. Then in FTView I detect the PC's (or these days thin client) IP address and use that in a lookup table on an SQL server (but you could use an array of local tags) to know where it is so it writes to the correct HMI_x tag.
 

Similar Topics

Hello! I am a newbie trying to troubleshoot/solve an issue with FactoryTalk trends. I have found answers on this fourm before, and am hoping...
Replies
13
Views
3,498
I have several trends setup in ViewSE 8.1 using HistorianSE data - none will show the current value in the legend caption. The min/max show...
Replies
3
Views
2,479
I have two identical machines running similar HMI projects, the only difference is one is done in FactoryTalk View Version 10 and the other is...
Replies
3
Views
131
how to communicate FactoryTalk Optix and Mitsubishi Q Series. I want to know the details of that
Replies
0
Views
39
Hoping someone can give me some guidance or confirmation of what I need to do. We have a FactoryTalk SE program that I need to change the IP...
Replies
2
Views
96
Back
Top Bottom