273
Views
5
Comments
Solved
Users cant be deleted

When I try to delete a user via espaceurl/users, I get the error:

The DELETE statement conflicted with the REFERENCE constraint "OSFRK_OSUSR_S4Y_MYUSERTABLE_OSSYS_USER_USERID". The conflict occurred in database "ELJJSW017", table "dbo.OSUSR_S4Y_MYUSERTABLE", column 'USERID'. The statement has been terminated.

How should I delete users now?

Info: I'm using platform version 11, but I had the same problems with Outsystems 10

Rank: #96
Solution

This seems like a very straightforward error.
Let's take a look at this error message:

The DELETE statement conflicted with the REFERENCE constraint "OSFRK_OSUSR_S4Y_MYUSERTABLE_OSSYS_USER_USERID". The conflict occurred in database "ELJJSW017", table "dbo.OSUSR_S4Y_MYUSERTABLE", column 'USERID'. The statement has been terminated.

What this means is, that when trying to delete a record from User entity, a reference / linked attribute was found in "MyUserTable", specifically in the column called "UserId".
Therefore the SQL query was terminated.


So if you wish to remove a user, you need to ofcourse delete the reference to this user in all entities which use it.
Or you could just setup a cascading delete for this entity.

You can do this by going to your MyUserTable entitiy, and selecting the UserId attribute, here you set the Delete rule to Delete.

Staff
Rank: #70

Hi Michael,

you are probably using that UserId (foreign key) on  one of the records (from another entity) on your app. 

Did you created a table called MyUserTable? probably that user Id is being used there. So before you be able to delete your users, you need to make sure you clear all the data that is referencing that user Id. 

Vera

Rank: #96
Solution

This seems like a very straightforward error.
Let's take a look at this error message:

The DELETE statement conflicted with the REFERENCE constraint "OSFRK_OSUSR_S4Y_MYUSERTABLE_OSSYS_USER_USERID". The conflict occurred in database "ELJJSW017", table "dbo.OSUSR_S4Y_MYUSERTABLE", column 'USERID'. The statement has been terminated.

What this means is, that when trying to delete a record from User entity, a reference / linked attribute was found in "MyUserTable", specifically in the column called "UserId".
Therefore the SQL query was terminated.


So if you wish to remove a user, you need to ofcourse delete the reference to this user in all entities which use it.
Or you could just setup a cascading delete for this entity.

You can do this by going to your MyUserTable entitiy, and selecting the UserId attribute, here you set the Delete rule to Delete.

I succeed by deleting , it's because of referenced UserId in other entities with 'protect' Delete Rule.

Just change it to 'Delete' or 'Ignore' depends on which option you want to delete.

Here are the main instructions explain the Delete Rule : 


Hi Joey moree,

if the referential integrity is mapped to outsystems_dev database and users table, doing this cascade delete will have impact on the entire system and outsystems blocks such delete operations. 



SampleError.JPG