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

Question

Question

Check if form submitter is within a team

asked on December 8, 2017

Hi, does anyone have an idea how to check if the submitter in Message Start Event is in a certain team in Forms? At the moment I have written a stored procedure to check the records in the cf_users, team_members and teams table, but have found that when removing or adding a user to a team, Forms does not delete the record in the team_members but rather update the leave date column or insert a new row with the join date.

 

This causes an issue as I need to check whether that user is in the team at that very moment regardless of whether the user has joined or left the team in the past. Below is the stored procedure I have written, where I pass the username of the initiator as the input parameter.

 

CREATE PROCEDURE [dbo].[CheckUserInTeam]
      @Username VARCHAR(50)
AS
BEGIN
      SET NOCOUNT ON;
 
      DECLARE @InTeam INT
 
      IF EXISTS(SELECT username, email, team_id, name, leave_date FROM cf_users
				inner JOIN team_members ON team_members.user_id = cf_users.user_id
				inner JOIN teams ON teams.id = team_members.team_id
				WHERE username = @Username AND name = 'Management Team')
      BEGIN
            SET @InTeam = 1
      END
      ELSE
      BEGIN
            SET @InTeam = 0
      END
 
      RETURN @InTeam
END

 

Thanks

0 0

Replies

replied on December 10, 2017

You are right, if leave_date is not null then the user does not belong to the team any longer.

I think you just need to edit the where condition and add "AND leave_date is null"

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

Sign in to reply to this post.