Home | Forums | Contact | Search | Syndication  
 
 [login] [create account]   Wednesday, February 19, 2025 
 
slxdeveloper.com Community Forums  
   
The Forums on slxdeveloper.com are now retired. The forum archive will remain available for the time being. Thank you for your participation on slxdeveloper.com!
 Architect Forums - SalesLogix Scripting & Customization
Forum to discuss writing script in Architect plugins for SalesLogix & general SalesLogix customization topics (for Windows client only). View the code of conduct for posting guidelines.
Forums RSS Feed


 Back to Forum List | Back to SalesLogix Scripting & Customization | New ThreadView:  Search:  
 Author  Thread: UserName
NebSeb
Posts: 49
 
UserNameYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 14 Jan 08 6:06 PM
I know how to get the UserID for whoever is logged in, but how do I get thier actual UserName

like I have userID U6UJ9A00002U and my name is Neb Seb, How do I find the Neb Seb through code so I can insert it into a record I am trying to create once somone saves thier actions on a form.

Any help is appreciated.

Thank you,
[Reply][Quote]
Ryan Farley
Posts: 2265
slxdeveloper.com Site Administrator
Top 10 forum poster: 2265 posts
 
Re: UserNameYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 14 Jan 08 6:22 PM
To get their full name:
select username from userinfo where userid = 'TheUserID'


Or their login name:
select usercode from usersecurity where userid = 'TheUserID'


-Ryan
[Reply][Quote]
NebSeb
Posts: 49
 
Re: UserNameYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 14 Jan 08 6:32 PM
I feel somewhat retarded asking this, but how do I assign a variable that value?


Dim tUserName = select username from userinfo where userid = 'TheUserID' ?
or what?

Sorry for the question, but my head is tired and i cant figure this one out.
[Reply][Quote]
Ryan Farley
Posts: 2265
slxdeveloper.com Site Administrator
Top 10 forum poster: 2265 posts
 
Re: UserNameYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 14 Jan 08 6:42 PM
Create an ADO recordset and open that query. Then get the value from the ADO recordset.

Dim rs 
Dim sUserName

Set rs = Application.GetNewConnection.Execute("select username from userinfo where userid = '" & useridvariable & "'")
sUserName = rs.Fields("username").Value
rs.Close
Set rs = Nothing

MsgBox "User name for " & useridvariable & " is " & sUserName


Make sense?

-Ryan
[Reply][Quote]
NebSeb
Posts: 49
 
Re: UserNameYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 14 Jan 08 6:51 PM
Yeah that makes sense.

Thank you,

Now here is another qustion..
Would this be the proper way to assign variables values?


Dim tHistoryID = application.basicfunctions.GetIDFor("HISTORY")
Dim tActivityID = application.basicfunctions.GetIDFor("HISTORY")
Dim tUserID = application.basicfunctions.CurrentUserID
Dim tCurrentGrade = plGrade.Text

I am getting a syntax error on the =

any ideas?
[Reply][Quote]
Ryan Farley
Posts: 2265
slxdeveloper.com Site Administrator
Top 10 forum poster: 2265 posts
 
Re: UserNameYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 14 Jan 08 6:54 PM
Hi Neb

I would suggest grabbing a VBScript book, it will make things much easier on you (just trying to be helpful ).

In VBScript, you cannot create a variable and assign it all on the same line like you can in VB.NET. You have to do:

Dim var
var = "My value"

Make sense?

-Ryan
[Reply][Quote]
NebSeb
Posts: 49
 
Re: UserNameYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 14 Jan 08 6:57 PM
Yeah, I have one at home I think i'll start to bring in. Im more used to C# and VB.Net than VBScript.

Thanks for your help, it is greatly appreciated.
[Reply][Quote]
Stephen Redmond
Posts: 190
 
Re: UserNameYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 15 Jan 08 2:35 AM
Quote:
Originally posted by Ryan Farley


Dim var
var = "My value"


One of our developers likes to do it like this:

Dim var : var = "My value"



Stephen
[Reply][Quote]
Mark Richardson
Posts: 25
 
Re: UserNameYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 15 Jan 08 2:55 AM
Hi NebSeb,
Just an observation that may make life a little easier,
Rather than having to use the syntax to create an ADO connection, SLX has a simpler method:

Dim uname
uname = GetField("USERNAME","USERINFO","USERID = '" & useridvariable & "'")

You can add extra conditions to this too if you want to ie:
uname = GetField("USERNAME","USERINFO","USERID = (select userid from history where historyid = '" & idvariable & "')")

To do it this way, just ensure you use the include script 'System:SLX Database Support' - The include script does the DB connection anyway...
[Reply][Quote]
Carla Tillman
Posts: 290
 
Re: UserNameYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 15 Jan 08 9:23 AM
NebSeb,

I usually access this by a SQL Function I've built. If you would like a copy of that, let me know.

Carla



[Reply][Quote]
NebSeb
Posts: 49
 
Re: UserNameYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 15 Jan 08 10:56 AM
would you mind posting the function you use so I can see how you have done this?
[Reply][Quote]
Carla Tillman
Posts: 290
 
Re: UserNameYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 15 Jan 08 11:11 AM
Here ya go.

USE [YourDBName]
GO

/*****************************************************************
Author: Carla Tillman; Informative Graphics Corporation
Use: Find the name of a SLX user
Notes: This script is not for Repackaging.
******************************************************************/

SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE FUNCTION [sysdba].[fn_GetUserName]
(
@UserID as VARCHAR(12)
)

RETURNS VARCHAR(64)as
BEGIN
DECLARE @USERNAME VARCHAR(64);

SET @USERNAME = (SELECT USERNAME FROM SYSDBA.USERINFO WHERE USERID = @USERID)
IF @USERNAME IS NULL
BEGIN
SET @USERNAME = 'USER_NOT_FOUND'
END

RETURN @USERNAME
END

***********************************************************

To use this:

From SLX

"Select sysdba.fn_GetUserName('" & Application.BasicFunctions.CurrentUserID & "')"

From SQL

PRINTsysdba.fn_GetUserName('userID')

OR

SELECT LastName, FirstName, ContactID, sysdba.fn_GetUserName(AccountManagerID) FROM Contact
WHERE LastName Like 'Smith%'

[Reply][Quote]
Stephen Redmond
Posts: 190
 
Re: UserNameYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 15 Jan 08 2:32 PM
If you are looking for the current user's name then:

Application.BasicFunctions.SystemInfoFor("Username")

will do the trick.

You can also use the Application.Users collection:


Application.Users.Item("UDEMOA00000I").Name
Application.Users.Item("UDEMOA00000I").NameFL
Application.Users.Item("UDEMOA00000I").NameFML

Stephen
[Reply][Quote]
Phil Parkin
Posts: 819
Top 10 forum poster: 819 posts
 
Re: UserNameYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 15 Jan 08 4:15 PM
Quote:
Originally posted by Stephen Redmond

If you are looking for the current user's name then:

Application.BasicFunctions.SystemInfoFor("Username")

will do the trick.

...


I like this one best
[Reply][Quote]
Dan Delisle
Posts: 38
 
Re: UserNameYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 29 Oct 14 9:29 AM

Hi Carla,


I'm trying to call a SQL function from SLX and having a heck of a time getting the return value. Could you possibly expand a little more on the 'From SLX' portion of your reply? How do you get the result of your function call to a edit box for example?


thank you


 

[Reply][Quote]
 Page 1 of 1 
  You can subscribe to receive a daily forum digest in your user profile. View the site code of conduct for posting guidelines.

   Forum RSS Feed - Subscribe to the forum RSS feed to keep on top of the latest forum activity!
 

 
 slxdeveloper.com is brought to you courtesy of Ryan Farley & Customer FX Corporation.
 This site, and all contents herein, are Copyright © 2025 Customer FX Corporation. The information and opinions expressed here are not endorsed by Sage Software.

code of conduct | Subscribe to the slxdeveloper.com Latest Article RSS feed
   
 
page cache (param): 2/19/2025 4:30:16 PM