Skip to Content
0

How to deactivate users from SAP CLM using script?

Mar 07 at 06:53 AM

27

avatar image
Former Member

Ans:

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.*;



//Deactivate user testing

void deactivateUser(){
NewUserAccountIBeanHomeIfc userHome = IBeanHomeLocator.lookup(session, NewUserAccountIBeanHomeIfc.sHOME_NAME);
String userEmail = "yyy.zzz@gmail.com";
String userID = "yyy.zzz";
//UserAccountIBeanIfc userBean = userHome.findUniqueByEmail(userEmail );
UserAccountIBeanIfc userBean = userHome.findByName(userID);
userHome.upgradeToEdit(userBean);
userBean.setIsInactive(true);
userHome.save(userBean);
//throw new ApplicationException(userBean +"");
}



deactivateUser(); Specifies the script for execution

10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

1 Answer

Best Answer
avatar image
Former Member Mar 07 at 06:59 AM
0

Above code will work fine. But you cannot delete user from CLM using script.

I have piece of code ,you guys can try.

//Delete User Testing


void deleteUser(){

userAccHome = (AbsAccountHomeIfc)HomeLocator.lookup(session, "upp.user_account");
user = (AbsAccountIfc)userAccHome .findUniqueByName("xyz@gmail.com");
userAccHome .upgradeToEdit(user);
userAccHome .delete(user);
}

Share
10 |10000 characters needed characters left characters exceeded