Event ID 31137 – Unable to removeadd Agent from Response Group

Recently I came across a situation where an Agent assigned to a response group had their SIP address changed by an administrator. Suddenly calls to this RGS were misbehaving, also their were 2 errors on the Lync FE server Event ID 31137 and 31138

Found the error by taking the SIP address from the Event  and looking for the user in the Lync database, thats when I noticed it had changed.
Seems Johan came across the same issue before and so here is how he has helped me find the issue..

Response Group agents not removed from dbo.Agents table
Original Article by Johan Veldhuis here

Warning: the procedure described in this blog are used as a workaround for an issue. Incorrect changes in the database may cause malfunctioning of the Response Groups.

In Lync 2010 it’s possible to add users to a group which can be used by the Response Groups. In some scenarios it might be necessary to remove and directly add an agent. This can be the case if a SIP address of a user needs to be changed.

Removing the agent is normally not an issue but adding it directly is. In almost every case the following error will be displayed:

Windows Powershell returned the following errors: 

Cannot insert duplicate key row in object dbo.Agents with unique index IX_Agents_UserSid.
The statement has been terminated.

This error will tell you that it can’t add the agent because there is an existing entry in the agent table which is used by the Response Groups.

Normally you will have to wait a few minutes before you can add the user again. But this week I experienced that after 3 hours the agent still can’t be added to the group. In the event log nothing strange was being logged. On TechNet you will not find many information how the Response Groups really perform this action. But in some cases it looks like the Response Group will be resetted after making a change and it only resets the Response Group if it is idle.

Because I couldn’t add the user after 3 hours it became quiet irritating. As you may know Lync is using SQL databases. The agents of a Response Group are added to the rgsconfigdatabase. This database can be found on the SQl server which also hosts the CMS.

Within this database you will find a table called dbo.Agents. When you will open this table you will see an overview of the agents which are member of the groups.

Perform the following steps to remove an agent from this table:
Right click on the dbo.Agents table and select the option Edit Top 200 rows
Search for the user and remove the specific record

By removing the record it will be possible to add the agent to the group again.

The issue is described in this KB article of Microsoft:



About Paul B

My name is Paul Bloem and I am employed at Lexel Systems in New Zealand as a Principal Consultant for Unified Communications. I have been working on enterprise voice solutions for over 20 years. My first 10 years were spent working for a Telco in South Africa (Telcom SA). This is where all the groundwork happened as I was exposed to just about every aspect of telecommunication you could imagine. I develop an interest in PBX technologies and eventually became the go-to guy. Next, I had a 10 year run at Siemens South Africa, most of my time there was as a Technical Trainer. During this time VoIP hit the world stage, I had the privilege of introducing VoIP both as H.323 and later SIP across the Siemens HiPath 4000 solution stack. In 2008 I immigrated to New Zealand with my newly attained MCSE, I was ready to go where no PBX Techie had gone before. I was employed to explore OCS 2007 and that was pretty much the beginning of the end for me. I have been working on OCS and Lync ever since. My current role focuses exclusively on Lync and associated technologies.. That includes pre-sales, consulting, architecture and design, training and support. I even get to play in the development space from time to time - focus on play ;-) I was nominated as a Microsoft VTSP for Lync early in 2013 and also awarded Microsoft's MVP award for Lync in 2014.
This entry was posted in dbo.Agents, event id, Event ID 31137, Event ID 31138, RGS. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s