Foren
How to get OrganizationId after login?
Tanaji M. Londhe, geändert vor 11 Jahren.
How to get OrganizationId after login?
Regular Member Beiträge: 194 Beitrittsdatum: 25.04.12 Neueste Beiträge
Hi,
How to access organizationId in my porltet class after successful login.
Thanks,
Tanaji.
How to access organizationId in my porltet class after successful login.
Thanks,
Tanaji.
Amit Doshi, geändert vor 11 Jahren.
RE: How to get OrganizationId after login?
Liferay Master Beiträge: 550 Beitrittsdatum: 29.12.10 Neueste Beiträge
Hi Tanaji,
You can check using below code snippet.
ThemeDisplay themeDisplay = (ThemeDisplay)renderRequest.getAttribute(WebKeys.THEME_DISPLAY);
if(themeDisplay.isSignedIn())
{
// Check the OrganizationLocalServiceUtil Class and use the method that meets your requirement.
}
Hope it helps.
Thanks & Regards,
Amit Doshi
You can check using below code snippet.
ThemeDisplay themeDisplay = (ThemeDisplay)renderRequest.getAttribute(WebKeys.THEME_DISPLAY);
if(themeDisplay.isSignedIn())
{
// Check the OrganizationLocalServiceUtil Class and use the method that meets your requirement.
}
Hope it helps.
Thanks & Regards,
Amit Doshi
Tanaji M. Londhe, geändert vor 11 Jahren.
RE: How to get OrganizationId after login?
Regular Member Beiträge: 194 Beitrittsdatum: 25.04.12 Neueste BeiträgeAmit Doshi:
Hi Tanaji,
You can check using below code snippet.
ThemeDisplay themeDisplay = (ThemeDisplay)renderRequest.getAttribute(WebKeys.THEME_DISPLAY);
if(themeDisplay.isSignedIn())
{
// Check the OrganizationLocalServiceUtil Class and use the method that meets your requirement.
}
Hope it helps.
Thanks & Regards,
Amit Doshi
Hi Amit,
If I use this code OrganizationLocalServiceUtil.getOrganizationId(companyId, name) what is second String name parameter.
Thanks,
Tanaji.
Jitendra Rajput, geändert vor 11 Jahren.
RE: How to get OrganizationId after login?
Liferay Master Beiträge: 875 Beitrittsdatum: 07.01.11 Neueste Beiträge
If you need current Group/organization/community id then you can directly get it using ThemeDisplay
ThemeDisplay themeDisplay = (ThemeDisplay)renderRequest.getAttribute(WebKeys.THEME_DISPLAY);
themeDisplay.getScopeGroupId()
Tanaji M. Londhe, geändert vor 11 Jahren.
RE: How to get OrganizationId after login?
Regular Member Beiträge: 194 Beitrittsdatum: 25.04.12 Neueste BeiträgeJitendra Rajput:
If you need current Group/organization/community id then you can directly get it using ThemeDisplayThemeDisplay themeDisplay = (ThemeDisplay)renderRequest.getAttribute(WebKeys.THEME_DISPLAY); themeDisplay.getScopeGroupId()
Hi Jitendra,
It doesnt give me OrgnizationId. It gives another id becuse I check in db table.
Thanks,
Tanaji
Tejas Kanani, geändert vor 11 Jahren.
RE: How to get OrganizationId after login?
Liferay Master Beiträge: 654 Beitrittsdatum: 06.01.09 Neueste Beiträge
This might help,
ThemeDisplay themeDisplay = (ThemeDisplay)renderRequest.getAttribute(WebKeys.THEME_DISPLAY);
Group group = themeDisplay.getScopeGroup();
long organizationId = 0;
if(group.isOrganization()) {
organizationId = group.getOrganizationId();
}
Tanaji M. Londhe, geändert vor 11 Jahren.
RE: How to get OrganizationId after login?
Regular Member Beiträge: 194 Beitrittsdatum: 25.04.12 Neueste Beiträge
Hi,
Hi Tejas I use your code but it gives me 0 value.
ThemeDisplay themeDisplay = (ThemeDisplay) renderRequest.getAttribute(WebKeys.THEME_DISPLAY);
List<Organization> list = OrganizationLocalServiceUtil.getUserOrganizations(userId) ;
Iterator<Organization> iterator = list.iterator();
while(iterator.hasNext()) {
organizationId = iterator.next().getOrganizationId();
}
I use this code.
This method is also useful as Amit said in above post "OrganizationLocalServiceUtil.getOrganizationId(companyId, name)" .
Hi Tejas I use your code but it gives me 0 value.
ThemeDisplay themeDisplay = (ThemeDisplay) renderRequest.getAttribute(WebKeys.THEME_DISPLAY);
List<Organization> list = OrganizationLocalServiceUtil.getUserOrganizations(userId) ;
Iterator<Organization> iterator = list.iterator();
while(iterator.hasNext()) {
organizationId = iterator.next().getOrganizationId();
}
I use this code.
This method is also useful as Amit said in above post "OrganizationLocalServiceUtil.getOrganizationId(companyId, name)" .
Tejas Kanani, geändert vor 11 Jahren.
RE: How to get OrganizationId after login?
Liferay Master Beiträge: 654 Beitrittsdatum: 06.01.09 Neueste Beiträge
It's good that its working for you now.
And if you have created any organization(not Site) and if you put your portlet in any of its page.
If you try to get organizationId using my code, ideally it should return you desired organizationId.
And if you have created any organization(not Site) and if you put your portlet in any of its page.
If you try to get organizationId using my code, ideally it should return you desired organizationId.
Tanaji M. Londhe, geändert vor 11 Jahren.
RE: How to get OrganizationId after login?
Regular Member Beiträge: 194 Beitrittsdatum: 25.04.12 Neueste Beiträge
Hi Tejas,
As you said, I create 1 Organization and 1 user as a Admin for the that org.
I use following code snippet
ThemeDisplay themeDisplay = (ThemeDisplay) renderRequest.getAttribute(WebKeys.THEME_DISPLAY);
Group group = themeDisplay.getScopeGroup();
long organizationId = 0;
if(group.isOrganization()) {
organizationId = group.getOrganizationId();
System.out.println("-----------------> organizationId = "+organizationId);
}
Still it will give me orgId=0. I think my organization is not a group. Thats why it gives me zero value.
As you said, I create 1 Organization and 1 user as a Admin for the that org.
I use following code snippet
ThemeDisplay themeDisplay = (ThemeDisplay) renderRequest.getAttribute(WebKeys.THEME_DISPLAY);
Group group = themeDisplay.getScopeGroup();
long organizationId = 0;
if(group.isOrganization()) {
organizationId = group.getOrganizationId();
System.out.println("-----------------> organizationId = "+organizationId);
}
Still it will give me orgId=0. I think my organization is not a group. Thats why it gives me zero value.
Jignesh Vachhani, geändert vor 11 Jahren.
RE: How to get OrganizationId after login?
Liferay Master Beiträge: 803 Beitrittsdatum: 10.03.08 Neueste Beiträge
you can use below code to get organization id of logged in user :
Here you will get list of organization ids for login user.
ThemeDisplay themeDisplay = (ThemeDisplay)renderRequest.getAttribute(WebKeys.THEME_DISPLAY);
themeDisplay.getUser().getOrganizations();
Here you will get list of organization ids for login user.
Hitoshi Ozawa, geändert vor 11 Jahren.
RE: How to get OrganizationId after login?
Liferay Legend Beiträge: 7942 Beitrittsdatum: 24.03.10 Neueste BeiträgeHow to access organizationId in my porltet class after successful login.
If you only want to get organizationId of user who logged in, just get the user from themeDisplay and get organizationId.
User user2 = themeDisplay.getUser();
long[] orgId = user2.getOrganizationIds();
Tanaji M. Londhe, geändert vor 11 Jahren.
RE: How to get OrganizationId after login?
Regular Member Beiträge: 194 Beitrittsdatum: 25.04.12 Neueste BeiträgeHitoshi Ozawa:
How to access organizationId in my porltet class after successful login.
If you only want to get organizationId of user who logged in, just get the user from themeDisplay and get organizationId.
User user2 = themeDisplay.getUser();
long[] orgId = user2.getOrganizationIds();
Hi Hitoshi,
Thanks its working properly.
Thanks,
Tanaji
Jignesh Vachhani, geändert vor 11 Jahren.
RE: How to get OrganizationId after login?
Liferay Master Beiträge: 803 Beitrittsdatum: 10.03.08 Neueste Beiträge
Doesn't look like the same code which i provided ?
ThemeDisplay themeDisplay = (ThemeDisplay)renderRequest.getAttribute(WebKeys.THEME_DISPLAY);
themeDisplay.getUser().getOrganizations();
ThemeDisplay themeDisplay = (ThemeDisplay)renderRequest.getAttribute(WebKeys.THEME_DISPLAY);
themeDisplay.getUser().getOrganizations();