Coming soon: Your brand new Help Center & Community! Get a sneak-peek here

Remove members from selection error

Hello,

I'm not sure if this is the correct forum for this but here it goes.

I want to add members to a selection using the REST API: /api/v1/Selection/{selectionId}/Members/AddPerson. The selection is static.

Here is a sample body of the POST request:

[
	{
		"PersonId": 123,
		"ContactId": 321
	}
]

When performing the request it works without any problems and when I look in the Super Office application the members are displayed as they should. However, when I remove a member from the selection in the application, I sometimes get this error:

In the database I see that the "memberCount" for the selection is "-1". I can no longer add members through the API, but adding member in the application "fixes" the error. The "memberCount" column corrects to the correct number and members are shown again (except the one that was removed).

Why does this error occur?

- Christian

RE: Remove members from selection error

Hi Christian, this is one of those error that keeps popping up now and then. Each time I've seen it its been related to adding and removing selectionmembers via webservices. For some reason it wrongly updates the memberCount to -1.

f you can reproduce it then that would be interresting.

Possible reasons could be that adding the same person twice could cause problems. Or perhaps something with timing? Or trying to remove a member that isn't in the selection? Or perhaps the selection contains some members your're not allowed to view?

No matter the reason SuperOffice should have some sort of validation when it updates the memberCount field so that it can never be less than 0.

Af: Frode Lillerud 11. okt 2018

RE: Remove members from selection error

I for one, like my yellow error messages in the archives of the Win client!
They have served me well when adopting the Netsever archive providers:-)

I wonder whether the selection.memberCount field could be dropped?
The Win client stopped caring about it a loooong time ago.

A quick look at UpdateMemberCount in our Selection Model showed this code with comment:

assert( i_NewCount >= 0 );
if ( i_NewCount < 0 )
   i_NewCount = 0; // Else Netserver provider will kick ass!

 

/conrad.

Af: Conrad Weyns 11. okt 2018

RE: Remove members from selection error

Hehe, nice! Then at least we know Win isn't to blame!

Af: Frode Lillerud 12. okt 2018

RE: Remove members from selection error

Thanks for responding!

I just tried with a brand new test selection, first adding myself as a member (through the API), then removing myself from the selection without any problems. Then I added myself again and another member. When I removed the other member I got the error again.

I also get the error when I am the only member and removing myself.

Adding selection members this way is not a reliable way then since I seem to get this error a lot.

Af: Christian Aashamar 15. okt 2018

RE: Remove members from selection error

Hi, in the API i believe there are multiple ways to add/remove members.

Which methods do you use for adding and removing?

Af: Frode Lillerud 15. okt 2018

RE: Remove members from selection error

Add member: /api/v1/Selection/{selectionId}/Members/AddPerson

Remove member: /api/v1/Selection/{selectionId}/Members/RemovePerson

Af: Christian Aashamar 15. okt 2018

RE: Remove members from selection error

And which SuperOffice version is this?

Af: Frode Lillerud 15. okt 2018

RE: Remove members from selection error

I've spent an hour trying to reproduce it on my machine, but haven't been able to. I'm on version 8.4, and no matter how hard I try I can't get SuperOffice to set a negative value in memberCount. Perhaps something has been fixed lately.

Coincidentally this happened at one of our customers today as well.

Af: Frode Lillerud 15. okt 2018

RE: Remove members from selection error

The version is 8.2.6642.1034

Af: Christian Aashamar 16. okt 2018