Skip to Content
avatar image
Former Member

How to deactivate users from SAP CLM using script?

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

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

1 Answer

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

    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);
    }

    Add comment
    10|10000 characters needed characters exceeded