Hi,

I want to delete end users except admin, how I can do that other than users module. I'm trying to use advanced query but it's not working, does anyone know the syntax?

Solution

Hey Abeer,

I guess there must be some issue with foreign key (user id in other tables) has delete rule has Protect as like below image. If am correct when you trying to delete users it is outsystems checks in back ground about this rule and works accordingly.  If you really wanted to delete first of all you need to clear all the occurrences of those foreign key values with null identifier.



Hope this may helps you..


Thanks & regards,

Ramakrushnarao Seera

Solution

Hello


Instead of trying to use advance query to delete the users use the outsystems function in users.

use an agregate to get all users  except the ones you do nto want to delete and then do a foreach  and remove one at time with "delete Users action"

Hi,


it is advisable to use aggregate, as quoted by Carlos Eduardo.


another alternative is by Sql Advanced query:


delete {Table} from {table} where {table}.[atributte] != x

Marcilio Ferreira wrote:

Hi,


it is advisable to use aggregate, as quoted by Carlos Eduardo.


another alternative is by Sql Advanced query:


delete {Table} from {table} where {table}.[atributte] != x


i don't think  you can use advance query with delete to delete the users table because you need to be in the same module that entity is in order to use a delete instruction and users entity is a system entity there is no module for it.

Carlos Gonçalves wrote:

Marcilio Ferreira wrote:

Hi,


it is advisable to use aggregate, as quoted by Carlos Eduardo.


another alternative is by Sql Advanced query:


delete {Table} from {table} where {table}.[atributte] != x


i don't think  you can use advance query with delete to delete the users table because you need to be in the same module that entity is in order to use a delete instruction and users entity is a system entity there is no module for it.


That's not true. You can delete from other modules just fine as long as "Expose Read Only" is set to "No" on the Entity, which is the case for Users.

Ramakrushnarao Seera (above) has the correct answer, the problem is going to be delete rules/constraints stopping the delete from succeeding, and an advance SQL is likely the best way to handle this.

J.Ja

Justin James wrote:

Carlos Gonçalves wrote:

Marcilio Ferreira wrote:

Hi,


it is advisable to use aggregate, as quoted by Carlos Eduardo.


another alternative is by Sql Advanced query:


delete {Table} from {table} where {table}.[atributte] != x


i don't think  you can use advance query with delete to delete the users table because you need to be in the same module that entity is in order to use a delete instruction and users entity is a system entity there is no module for it.


That's not true. You can delete from other modules just fine as long as "Expose Read Only" is set to "No" on the Entity, which is the case for Users.

Ramakrushnarao Seera (above) has the correct answer, the problem is going to be delete rules/constraints stopping the delete from succeeding, and an advance SQL is likely the best way to handle this.

J.Ja

You are right i normaly use actions to do the cruds and have entities and expose read only as true, that's why it does not work outside the module.


Carlos Gonçalves wrote:

Justin James wrote:

Carlos Gonçalves wrote:

Marcilio Ferreira wrote:

Hi,


it is advisable to use aggregate, as quoted by Carlos Eduardo.


another alternative is by Sql Advanced query:


delete {Table} from {table} where {table}.[atributte] != x


i don't think  you can use advance query with delete to delete the users table because you need to be in the same module that entity is in order to use a delete instruction and users entity is a system entity there is no module for it.


That's not true. You can delete from other modules just fine as long as "Expose Read Only" is set to "No" on the Entity, which is the case for Users.

Ramakrushnarao Seera (above) has the correct answer, the problem is going to be delete rules/constraints stopping the delete from succeeding, and an advance SQL is likely the best way to handle this.

J.Ja

You are right i normaly use actions to do the cruds and have entities and expose read only as true, that's why it does not work outside the module.



The User entity is exposed with "Expose Read Only" = "No". There are no problems deleting User from another module.

J.Ja