You are viewing limited content. For full access, please sign in.

Question

Question

Query to return Forms teams that a user is a member

asked on October 18, 2017 Show version history

Hi team,

I have a process where the first task is assigned to a user from a variable.

This step works by setting the user in the format domain\username.

The following task needs to be assigned to the Team that the initial user is a member.

Is there a query or method that could execute on the Forms db tables to determine the Team name/s of a user as a variable that be used in the Assign by Variable setting?

 

many thanks

 

0 0

Answer

SELECTED ANSWER
replied on October 18, 2017

Hey,

This is the SQL code for a query to return usernames and their associated teams.

SELECT username, email, team_id, name FROM LFForms.dbo.cf_users
inner JOIN LFForms.dbo.team_members ON team_members.user_id = cf_users.user_id
inner JOIN LFForms.dbo.teams ON teams.id = team_members.team_id

There will be one record per person per team. To get what you need you can turn this into a view to query directly or a stored procedure and pass in the user you are looking for specifically.

Hope that helps.

0 0
replied on October 19, 2017

Hi Aaron

The query does exactly what I wanted.

Many thanks.

 

 

0 0
replied on October 23, 2018

How would you change this query to only pull unique "usernames" values regardless of the team they belong to?

1 0
replied on June 11, 2021

This query doesn't check for deleted or active users.  How do I ensure it is only the current group members?  We recently converted to LFDS and there is a lot of extra data in my query now.  please help?

0 0
replied on June 16, 2021

Most of these tables have a flag of some sort to indicate whether a row is still active:

SELECT
	u.username
	,u.email
	,tm.team_id
	,t.[name]
	FROM LF_Forms.dbo.cf_users u
	INNER JOIN LF_Forms.dbo.team_members tm
		ON u.[user_id] = tm.[user_id]
		AND tm.leave_date IS NULL
	INNER JOIN LF_Forms.dbo.teams t
		ON t.id = tm.team_id
		AND t.is_deleted = 0
	WHERE u.is_activated = 1
	;

 

0 0

Replies

You are not allowed to reply in this post.
You are not allowed to follow up in this post.

Sign in to reply to this post.