Ask Questions and Find Answers
Important:
Ask is now read-only. You can review any existing questions and answers, but not add anything new.
But - don't panic! While ask is no more, we've replaced it with discuss - the new Liferay Discussion Forum! Read more here here or just visit the site here:
discuss.liferay.com
RE: delete liferay user programmatically
I tested this code but it does not work :
User u=UserLocalServiceUtil.getUser(11612) ;
UserLocalServiceUtil.updateStatus(u.getUserId() ,WorkflowConstants.STATUS_INACTIVE); //inactive user
UserLocalServiceUtil.deleteUser(u.getUserId()); //delete user
thanks for your help
It throws an exception?
It appears to work but user is still in database?
User shows up in search?
com.liferay.portal.NoSuchGroupException: No Group exists with the key {companyId=10154, classNameId=10190, classPK=100601}
Normally I never delete users, just mark them as inactive. They cannot log in, they don't appear in searches, it leaves all of their stuff (forum posts, wiki pages, etc.) referencing existing user records, ...
this list contains active and inactive users ! So how can I have just the list of active users ?
thank you
My code :
DynamicQuery dynamicQuery = UserLocalServiceUtil.dynamicQuery();
dynamicQuery.add(RestrictionsFactoryUtil.ne("status", 5));
int startOfList = QueryUtil.ALL_POS;
int endOfList = QueryUtil.ALL_POS;
List<user> listuser=UserLocalServiceUtil.dynamicQuery(dynamicQuery,QueryUtil.ALL_POS, QueryUtil.ALL_POS);
</user>
It throws this exception :
com.liferay.portal.NoSuchGroupException: No Group exists with the key {companyId=10154, classNameId=10190, classPK=100601}
This probably means you deleted the Default User, you can check for this in your code user.isDefaulUser() (returns true/false).
Old post I know but in case anyone else is looking at this.
God post. Almost our problem. I guess that default user has been deleted and with it the group matching these 3 keys. But now we have a new default user with no matching group. How do I recreate matching group? Or can I create a new default user and group is automatically created?asto d:
It throws this exception :
com.liferay.portal.NoSuchGroupException: No Group exists with the key {companyId=10154, classNameId=10190, classPK=100601}
This probably means you deleted the Default User, you can check for this in your code user.isDefaulUser() (returns true/false).
Old post I know but in case anyone else is looking at this.
Hello,
I am trying to write a Groovy script which helps to delete users based on user id given in the if condition.
import com.liferay.portal.kernel.service.UserLocalServiceUtil
try{
userCount = UserLocalServiceUtil.getUsersCount()
users = UserLocalServiceUtil.getUsers(0, userCount)
for (user in users) {
if(user.getUserId()==36615){
println("User
Name: " + user.getFullName() + " -- " +
user.getAgreedToTermsOfUse()+" Email address:
"+user.getEmailAddress()+" User ID:
"+user.getUserId());
UserLocalServiceUtil.deleteUser(user);
}}
}catch(e){
out.println("""<div
class="portlet-msg-error">${e}</div>""")
e.printStackTrace(out)
}
But, it
gives "com.liferay.portal.kernel.exception.ModelListenerException:
java.lang.NullPointerException"
Please help to resolve the same.
Thanks
Taruchit
You'd have to provide the stack trace. Obviously the model listener is expecting something to be there that isn't, but it isn't clear if this is a Liferay model listener or a home-grown model listener.
Hey David,
The stack trace is here:
https://community.liferay.com/forums/-/message_boards/view_message/110981462
However I don't know why Taruchit has not opened a new thread? Taruchit, don't you permissions to open a new thread?
Regarding the issue it seems that the exception is thrown in a Social Office portlet:
at com.liferay.social.office.upgrade.association.internal.model.listener.UserModelListener.onAfterRemoveAssociation(UserModelListener.java:193)
If you don't use it, could you uninstall social office and execute the script again?
Hello David,
Following is the stack trace for the issue: -
https://community.liferay.com/de/forums/-/message_boards/message/111015368
Taruchit Goyal
HI i need a developer to do some work on eCommerce checkout page can any one help me with their right charges.