on 2016 May 05 4:10 PM
Hello Experts,
I'm using CLM and in our system we have a lot of user accounts which are not used. When I check in our db the column name "date_last_loggedin" it is null. I would like to delete all that type of accounts, so I was trying to do this with one of our test accounts and I was using this script:
import com.sap.odp.api.common.types.*;
import com.sap.odp.api.ibean.*;
import com.sap.odp.api.usermgmt.masterdata.*;
import com.sap.odp.api.doc.DocLinkDefinitionTypeEnumType;
import com.sap.odp.api.doc.DocumentLinkIBeanIfc;
import com.sap.odp.api.common.log.*;
import java.io.PrintWriter;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.io.FileOutputStream;
import com.sap.eso.api.doccommon.doc.contract.*;
import java.util.Hashtable;
import com.sap.odp.api.doc.collaboration.*;
import java.util.Calendar;
import com.sap.odp.api.doccommon.masterdata.*;
import com.sap.odp.api.doccommon.userdefined.*;
import com.sap.eso.api.contracts.*;
import java.util.List;
import com.sap.odp.common.directory.*;
userHome = (AbsAccountHomeIfc)HomeLocator.lookup(session, "upp.user_account");
String userID = "testuser1";
user = (AbsAccountIfc)userHome.findUniqueByName(userID);
userHome.delete(user);
But I got an error "Database error: The record cannot be removed because it is currently active.". When I changed user to be Inactive and ran code again I got another error "You cannot modify the business object because it is not editable. Click Edit This Document at the top of the page to make this document editable.".
Have you got idea how to delete users using script(this is my goal) and solve this problem?
Thanks for help.
Request clarification before answering.
Hi
Please use
userHome.upgradeToEdit(user);
userhome.delete(user):
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello,
With help of Venkateswararao Vasantha I made a change in my code, now it looks like below:
user = (AbsAccountIfc)userHome.findUniqueByName(userID);
userHome.upgradeToEdit(user);
userHome.delete(user);
userHome.save(user);
This code is in try-catch block. When I ran the code again it went to catch section suggesting potential error, but when I save the result of Exception - e.getMessage() it gives me only string with "null".
How to solve this problem and what to do next?
Thanks for your help.
Hmm, sorry for the 'pun'
If you have access to the logs, you need to check the full stack trace. But ... by the looks of things it might not be possible to fully delete the user.
I'll do some checking and get back; maybe you could also get your hands on the stack trace (you can check online how to write it to a string using PrintWriter)
Bogdan
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.