The CreatorCon Call for Content is officially open! Get started here.

how to delete a particular user from User(sys_user) table.

praveen1231
Tera Contributor

Hi,

My scenario is - I had created a new catalog item variable called User(Referrence field). When I select any particular user (e.g. Abel Tuter) and submit the catalog item record, selected user (Abel Tuter) needs to delete permanently from the User(sys_user) table. Please let me know if you have any idea regarding this. Thanks

1 ACCEPTED SOLUTION

Hi @praveen1231,

 

I understand that is the requirement, however part of our job is to give advice.

 

Not every requirement should be fulfilled if there are better ways to do it, or if it is better to not do it at all.

 

I'll leave it up to you what to do with that. Just keep in mind a trusted advisor is valued even more than a good developer. 

 

That being said, since you are using a catalog item, the easiest way to handle it, is to create a flow with flow designer.

 

Lookup the user from the variables, update the user, or delete if there is is no other way forward.


Help others to find a correct solution by marking the appropriate response as accepted solution and helpful.

View solution in original post

11 REPLIES 11

Sandeep Rajput
Tera Patron
Tera Patron

@praveen1231 You can simply choose to create workflow/flow which will be used as a process engine on your Catalog item.

Screenshot 2023-09-29 at 9.26.50 PM.png

Inside the flow/workflow you can extract the user reference variable from the requested item, and use a Run Script Activity/Delete Record step to delete the record from the sys_user table.

 

Hope this helps.

@Sandeep Rajput Can you please share some screenshots regarding the script. It must help me to solve. Thanks

Jaspal Singh
Mega Patron
Mega Patron

Hi Praveen,

As suggested in comments before ideal is to get the profiles marked inactive instead of deleting it. Also, did you try something already? If so, where are you stuck?

Thanks for your reply @Jaspal Singh. My requirement is to delete the particular user from User(sys_user) table who is selected in reference field. Actual scenario is User(sys_user) is considered as employee. When employee quit his job and left the company, company will send a form to the employee and employee need fill it with his details and when he submits the form employee details will get delete from the company portal. And finally, I got the output. Thank you😇.

@praveen1231 Thank you for the details. However the question is why delete? ServiceNow has logical deletion (Active: True/False) why not use that instead of physical deletion.

Hope the solution you opted for is logical deletion and not physical deletion.