Foren
can any one tell me... how to Add user to organization, programmatically
piyush shukla, geändert vor 8 Jahren.
can any one tell me... how to Add user to organization, programmatically
Junior Member Beiträge: 46 Beitrittsdatum: 18.09.15 Neueste Beiträge
Add user to organization, programmatically? can you provide information about this
Harish Kumar, geändert vor 8 Jahren.
RE: can any one tell me... how to Add user to organization, programmaticall
Expert Beiträge: 483 Beitrittsdatum: 31.07.10 Neueste Beiträgepiyush shukla:
Add user to organization, programmatically? can you provide information about this
/**
* @throws SystemException if a system exception occurred
*/
public static void addOrganizationUser(long organizationId, long userId)
throws com.liferay.portal.kernel.exception.SystemException {
getService().addOrganizationUser(organizationId, userId);
}
piyush shukla, geändert vor 8 Jahren.
RE: can any one tell me... how to Add user to organization, programmaticall
Junior Member Beiträge: 46 Beitrittsdatum: 18.09.15 Neueste Beiträge
Hi Harish Kumar
but i just want to know- how to call this method addOrganizationUser
like this addOrganizationUser(organizationId,userIds); we will pass organizationId like this or is there any way for passing organizationId
i'm not sure about this calling method
but i just want to know- how to call this method addOrganizationUser
like this addOrganizationUser(organizationId,userIds); we will pass organizationId like this or is there any way for passing organizationId
i'm not sure about this calling method
Harish Kumar, geändert vor 8 Jahren.
RE: can any one tell me... how to Add user to organization, programmaticall
Expert Beiträge: 483 Beitrittsdatum: 31.07.10 Neueste Beiträge
UserLocalServiceUtil.addOrganizationUser(organizationId,userId)
pass the organization id and user id ;
pass the organization id and user id ;
Piyush Shukla, geändert vor 8 Jahren.
RE: can any one tell me... how to Add user to organization, programmaticall
Junior Member Beiträge: 46 Beitrittsdatum: 18.09.15 Neueste Beiträge
Hi Harish
// i'm calling like this method regularOrg and OrgUser method inside updateInstance
Organization org = null;
org = CreateRegularOrg(companyName, company.getCompanyId());
addOrganizationUser(org, tenantAdminName,tenantAdminEmailId);
//this method for create regularOrganization(this is woking fine for me (regular organization is creating))
SuppressWarnings({ "unused", "deprecation" })
private Organization CreateRegularOrg(String tenant, long companyId) {
ServiceContext serviceContext = ServiceContextThreadLocal
.getServiceContext();
serviceContext.setCompanyId(companyId);
Organization org = null;
try {
org = OrganizationServiceUtil.addOrganization(0, tenant,"regular-organization", true, 19014, 19, 12017,StringPool.BLANK, true, serviceContext);
org.setCompanyId(companyId);
org = OrganizationLocalServiceUtil.updateOrganization(org);
org.getExpandoBridge().setAttribute("tenant ", tenant);
} catch (PortalException e) {
e.printStackTrace();
} catch (SystemException e) {
e.printStackTrace();
}
return org;
}
Now i want to create user inside above regular organization(this code is not working for me user is not creating inside organization)
private void addOrganizationUser(Organization org, String tenantAdminName,String tenantAdminEmailId)
throws PortalException {
ServiceContext serviceContext = ServiceContextThreadLocal
.getServiceContext();
User user = null;
try {
Company company = CompanyLocalServiceUtil.getCompany(org.getCompanyId());
User newUser = UserLocalServiceUtil.createUser(CounterLocalServiceUtil.increment());
newUser.setFirstName(tenantAdminName);
newUser.setEmailAddress(tenantAdminEmailId);
newUser.setCompanyId(org.getCompanyId());
newUser.setScreenName(tenantAdminEmailId);
UserLocalServiceUtil.addOrganizationUser(org.getOrganizationId(),newUser);
UserLocalServiceUtil.addUser(newUser);
} catch (SystemException e) {
e.printStackTrace();
}
}
THANKS IN ADVANCE
please tell mehwre i'm doingmistake actually i'm new in liferay creating user and organizatin by programatically please help me out
// i'm calling like this method regularOrg and OrgUser method inside updateInstance
Organization org = null;
org = CreateRegularOrg(companyName, company.getCompanyId());
addOrganizationUser(org, tenantAdminName,tenantAdminEmailId);
//this method for create regularOrganization(this is woking fine for me (regular organization is creating))
SuppressWarnings({ "unused", "deprecation" })
private Organization CreateRegularOrg(String tenant, long companyId) {
ServiceContext serviceContext = ServiceContextThreadLocal
.getServiceContext();
serviceContext.setCompanyId(companyId);
Organization org = null;
try {
org = OrganizationServiceUtil.addOrganization(0, tenant,"regular-organization", true, 19014, 19, 12017,StringPool.BLANK, true, serviceContext);
org.setCompanyId(companyId);
org = OrganizationLocalServiceUtil.updateOrganization(org);
org.getExpandoBridge().setAttribute("tenant ", tenant);
} catch (PortalException e) {
e.printStackTrace();
} catch (SystemException e) {
e.printStackTrace();
}
return org;
}
Now i want to create user inside above regular organization(this code is not working for me user is not creating inside organization)
private void addOrganizationUser(Organization org, String tenantAdminName,String tenantAdminEmailId)
throws PortalException {
ServiceContext serviceContext = ServiceContextThreadLocal
.getServiceContext();
User user = null;
try {
Company company = CompanyLocalServiceUtil.getCompany(org.getCompanyId());
User newUser = UserLocalServiceUtil.createUser(CounterLocalServiceUtil.increment());
newUser.setFirstName(tenantAdminName);
newUser.setEmailAddress(tenantAdminEmailId);
newUser.setCompanyId(org.getCompanyId());
newUser.setScreenName(tenantAdminEmailId);
UserLocalServiceUtil.addOrganizationUser(org.getOrganizationId(),newUser);
UserLocalServiceUtil.addUser(newUser);
} catch (SystemException e) {
e.printStackTrace();
}
}
THANKS IN ADVANCE
please tell mehwre i'm doingmistake actually i'm new in liferay creating user and organizatin by programatically please help me out