I am installing layouts through the hook
with friendly url as follows
/cat1/link1, /cat1/link2
and
/cat2/link3, /cat2/link4
I want it insuch a way that when I navigate to cat1/link1
The nav links should be link1 and link2
and when i navigate to cat2/link3
The nav links should be link3 and link4
How can i achive this?
or can anyone suggest how can i group the layouts for multiple sites into different categories in same liferay install?
Thanks..
To create organization (this is from seven-cogs StartupAction.java)
long userId = defaultUserId;
long parentOrganizationId = OrganizationConstants.DEFAULT_PARENT_ORGANIZATION_ID;
String name = "7Cogs, Inc.";
String type = OrganizationConstants.TYPE_REGULAR_ORGANIZATION;
boolean recursable = true;
long regionId = 0;
long countryId = 0;
int statusId = GetterUtil.getInteger(PropsUtil.get("sql.data.com.liferay.portal.model.ListType.organization.status"));
String comments = null;
ServiceContext serviceContext = new ServiceContext();
serviceContext.setAddCommunityPermissions(true);
serviceContext.setAddGuestPermissions(true);
Organization organization =
OrganizationLocalServiceUtil.addOrganization(
userId, parentOrganizationId, name, type, recursable, regionId,
countryId, statusId, comments, serviceContext);
Group group = organization.getGroup();
GroupLocalServiceUtil.updateFriendlyURL(group.getGroupId(), "/7cogs");
Are you sure that you need two organizations and not two communities?
UPDATE for question in comment:
To get organization name in theme (velovity) you can use (if you are in organization's pages (group))
In portal-ext.properties
journal.template.velocity.restricted.variables=
In theme vm file
Liferay 6
#set($os = $serviceLocator.findService("com.liferay.portal.service.OrganizationLocalService"))
#set($organization = $os.getOrganization($themeDisplay.getScopeGroup().getOrganizationId()))
$organization.getName()
Liferay 5.x
#set($os = $serviceLocator.findService("com.liferay.portal.service.OrganizationLocalServiceUtil"))
#set($organization = $os.getOrganization($themeDisplay.getScopeGroup().getOrganizationId()))
$organization.getName()
EDIT:
If your user is member of organization(s) than you can use
#foreach($org in $themeDisplay.getUser().getOrganizations())
$org.getName()<br>
#end
Take note that user can be member of multiple organizations and you will get all of them.
What you need to know about the code:
From the same class Martin mentioned I've put together a mix of code that will achieve what you need.
Note that some of the variables are not defined. You'll have to use the correct values that are particular to your Liferay installation. For example, the userId could be anyone but I would suggest using either the default user's userId or an administrator's userId.
The Code:
Organization organization =
OrganizationLocalServiceUtil.addOrganization(
userId, OrganizationConstants.DEFAULT_PARENT_ORGANIZATION_ID,
"My Org 1", OrganizationConstants.TYPE_REGULAR_ORGANIZATION, true,
regionId, countryId, statusId, comments, true, serviceContext);
Group group = organization.getGroup();
GroupLocalServiceUtil.updateFriendlyURL(group.getGroupId(), "/cat1");
LayoutLocalServiceUtil.addLayout(
group.getCreatorUserId(), group.getGroupId(), "false",
LayoutConstants.DEFAULT_PARENT_LAYOUT_ID, "My Link 1", StringPool.BLANK,
StringPool.BLANK, LayoutConstants.TYPE_PORTLET, false, "/link1",
false, serviceContext);
LayoutLocalServiceUtil.addLayout(
group.getCreatorUserId(), group.getGroupId(), "false",
LayoutConstants.DEFAULT_PARENT_LAYOUT_ID, "My Link 2", StringPool.BLANK,
StringPool.BLANK, LayoutConstants.TYPE_PORTLET, false, "/link2",
false, serviceContext);
organization =
OrganizationLocalServiceUtil.addOrganization(
userId, parentOrganizationId, name, type, recursable, regionId,
countryId, statusId, comments, true, serviceContext);
group = organization.getGroup();
GroupLocalServiceUtil.updateFriendlyURL(group.getGroupId(), "/cat2");
LayoutLocalServiceUtil.addLayout(
group.getCreatorUserId(), group.getGroupId(), "false",
LayoutConstants.DEFAULT_PARENT_LAYOUT_ID, "My Link 3", StringPool.BLANK,
StringPool.BLANK, LayoutConstants.TYPE_PORTLET, false, "/link3",
false, serviceContext);
LayoutLocalServiceUtil.addLayout(
group.getCreatorUserId(), group.getGroupId(), "false",
LayoutConstants.DEFAULT_PARENT_LAYOUT_ID, "My Link 4", StringPool.BLANK,
StringPool.BLANK, LayoutConstants.TYPE_PORTLET, false, "/link4",
false, serviceContext);
Related
I have created one organizational unit inside my active directory and added a user inside that OU.
DistinguishedName : CN=Alex Shaun,OU=TestOU,DC=mydomain,DC=com
Enabled : True
GivenName : Alex
Name : Alex Shaun
ObjectClass : user
ObjectGUID : 16fc9afc-02a5-474f-8837-4e71853y1ceb
SamAccountName : alex
SID : S-1-5-21-233531163-xxxxxxx-2764101054-1604
Surname : Shaun
UserPrincipalName : alex#mydomain.com
After doing I synced that user into my azure using azure ad connect. Now I am using Microsoft Azure API to get user information but it does not contain any information regarding OU.
{
"businessPhones": [],
"displayName": "Alex Shaun",
"givenName": "Alex",
"jobTitle": null,
"mail": null,
"mobilePhone": null,
"officeLocation": null,
"preferredLanguage": null,
"surname": "Shaun",
"userPrincipalName": "alex#mydomain.com",
"id": "xxxx-0744-47cb-ad48-xxxxxxxx"
},
Azure Active Directory is a flat structure containing user, groups & computer objects
Azure Active Directory does not have OUs
So, you would not be able to see OU information in the Azure Active Directory
You can fetch onPremisesDistinguishedName property which contains OU.
It is returned only on $select. https://graph.microsoft.com/v1.0/users?$select=onPremisesDistinguishedName
This is the Question/Answer case, so here you wont find any details.
After Googling within few hours I found solution that you can find below.
simple_salesforce
from simple_salesforce import Salesforce
def custom_field_create:
"""
Based on https://salesforce.stackexchange.com/a/212747/65221
Examples of field types you can find in the column "Data Type" of the salesforce front end,
on the page where you can create/edit/delete fields for your selected object.
NOTE: case of "type" is important. For example the type "DateTime"
must be exactly "DateTime" and not like "datetime".
"""
email = 'your_email'
password = 'your_password'
security_token = 'your_token'
object_api_name = 'contact' # replace with your object name
field_api_name = 'Activity_Time' # replace with your field name
field_label = 'Activity Time' # replace with your field label
sf = Salesforce(username=email, password=password, security_token=security_token)
url = 'tooling/sobjects/CustomField/'
payload = {
"Metadata":
{"type": "Text", "inlineHelpText": "", "precision": None, "label": f"{field_label}", "length": 90, "required": False},
"FullName": f"{object_api_name}.{field_api_name}__c"
}
result = sf.restful(url, method='POST', json=payload)
print('result:', result)
I'm trying to get a collection of list items from a SharePoint through Microsoft Graph, which I want to filter by CreatedBy.
Requesting: https://graph.microsoft.com/v1.0/sites/{siteid}/lists/TeamRequests/items
Returns:
{
"#odata.context": "https://graph.microsoft.com/v1.0/$metadata#sites('{url}')/lists('TeamRequests')/items",
"value": [
{
"#odata.etag": "\"56ad787e-bd69-464a-b5da-dd953e40d7c4,13\"",
"createdDateTime": "2018-02-26T08:34:26Z",
"eTag": "\"56ad787e-bd69-464a-b5da-dd953e40d7c4,13\"",
"id": "11",
"lastModifiedDateTime": "2018-03-22T13:20:03Z",
"webUrl": "{url}/Lists/TeamRequests/11_.000",
"createdBy": {
"user": {
"email": "{email}",
"id": "9c9cbb67-c049-4a2d-845d-6c5ca2300041",
"displayName": "{Name}"
}
},
"lastModifiedBy": {
"user": {
"email": "{email}",
"id": "9c9cbb67-c049-4a2d-845d-6c5ca2300041",
"displayName": "{Name}"
}
},
"parentReference": {},
"contentType": {
"id": "0x01005F15F8133495554D834FF82F187AD0630002133A9CCDE4494D8CB2206D7D6453D6"
}
},
Now I'd like to filter this request for createdBy, either Id, displayName or email address. I tried ?$filter=createdBy/user/email eq '{email}' and similar requests for id or displayName. They all return
{
"error": {
"code": "generalException",
"message": "An unspecified error has occurred.",
"innerError": {
"request-id": "492e3bde-05fe-4484-a475-435ff0aa70b6",
"date": "2018-07-23T07:41:46"
}
}
}
So how to accomplish this filter? Is it even supported?
Even though it sounds like a straightforward query, i have not come up to anything more simple then the following solution:
It seems filtering by user field is not supported except the case when user id is provided, that's the reason why the solution consists of two steps:
1) First, we need to determine user Id by Email , for that purpose the following query could be utilized:
https://graph.microsoft.com/v1.0/sites/root/lists('User Information List')/items?expand=fields(select=Id,Email)
*where User Information List system list stores user properties including Id and Email properties *
2) Once the user Id is resolved, the final query to filter items by user id could be applied:
https://graph.microsoft.com/v1.0/sites/{site-id}/lists('list-name')/items?filter=fields/<user-field-name>LookupId eq '<user-id>'
where
<user-field-name>LookupId is a field which is getting exposed in addition to user field, in case of Created field the name should be AuthorLookupId
Example:
https://graph.microsoft.com/v1.0/sites/root/lists('TeamRequests')/items?filter=fields/AuthorLookupId eq '10'
Note
In some cases the following error is returned Field ''
cannot be referenced in filter or orderby as it is not indexed.
Provide the 'Prefer: HonorNonIndexedQueriesWarningMayFailRandomly'
header to allow this, but be warned that such queries may fail on
large lists.
In that case the following request header needs to be applied:
Prefer: HonorNonIndexedQueriesWarningMayFailRandomly
When I tried to access User Information List list. There is an error with list not found.
So since in my case, first I filtered list data based on status value and next step got the logged in user display name and filtered listitems based on display name.
I'm using #pnp/graph
Filter list data with status filter
let resultsList = await listItemsQuery.filter("fields/RequestStatus eq 'Approval Pending'").expand("fields").get<MicrosoftGraph.ListItem[]>();
Get Logged-In Profile:
const profileQueryEndPoint = new GraphQueryableCollection(graph.me, "/");
Select displayName property from above result
let profileData : User = await profileQueryEndPoint.select("displayName").get <User>();
console.log('displayName : ' + profileData['displayName']);
Filter ListItems with createdby Field by passing profileData['displayName']
let filterUserCreatedRequests: MicrosoftGraph.ListItem[] = resultsList.filter(ListItem => ListItem["createdBy"].user.displayName === profileData['displayName']);
Display filtered results
console.log('filterUserCreatedRequests : ' + JSON.stringify(filterUserCreatedRequests));
I'm giving all the steps for your reference. But above code can simplified more.
Hope this helps someone :)
Hello I'm generating some Entity with the jhipster generator.
When I generate an entity relationship, I'd like to make the value in that field mandatory but unfortunately, the generator doesn't provide that option.
Is there anyway to inform the generator of this necessity?
(editing the .jhipster/entity_name.json), for example?
Since this commit JHipster supports the required validation on relationships too.
This is an example from a JDL file:
relationship ManyToOne { Certificate{ca(name) required} to CertificateAuthority }
('Certificate' and 'CertificateAuthority' are entities and 'ca' is the field name)
The relevant part from the .jhipster/Certificate.json:
"relationships": [
{
"relationshipType": "many-to-one",
"relationshipValidateRules": "required",
"relationshipName": "ca",
"otherEntityName": "certificateAuthority",
"otherEntityField": "name"
},
The generated Certificate.ca field:
#ManyToOne
#NotNull
private CertificateAuthority ca;
And the generated form has a 'This field is required.' warning at the Ca filed.
No, it would be a new feature.
Feel free to create an issue in our github project and pull requests are always welcome :)
Just for others, here is the issue you opened
I am referring OrgChart Example here: https://github.com/AzureADSamples/WindowsAzureAD-GraphAPI-Sample-OrgChart
It has predefined set of properties that can be set at the time of user creation.
Can someone tell me how do I add Password property when creating a user
Thanks!
Check out the documentation for Create User. In your request body, it would look like this to set a password for the user:
{
"accountEnabled": true,
"displayName": "Alex Wu",
"mailNickname": "AlexW",
"passwordProfile": { "password" : "Test1234", "forceChangePasswordNextLogin": false },
"userPrincipalName": "Alex#contoso.onmicrosoft.com"
}
You can also check out the docs for Password profile to see what limitations exist for setting the password.