Create a node with an assoctiation to a user

cancel
Showing results for 
Search instead for 
Did you mean: 
panacasp
Active Member

Create a node with an assoctiation to a user

Hi,

 

I'm developing a UI using angular 7 and alfresco services, I'm trying to create a form page to allow creating new content in a datalist. This content must have an association with an user at the moment of creation, i'm sending the data to Create Node Children as follows:

 

"aspectNames": [
        "cm:auditable"
      ],
      "name": data.name,
      "nodeType": "myDataList",
      "properties": {
          "myProperty": data.name
      },
      "targets": [
        {
          "assocType": "myUserAssociation",
          "targetId" : userId
        }
      ]
 
The problem is how do I find the user node id. Search service gives me user properties like username, email, home folder, etc. but not node id.
 
Any sugestions on how can I find this info? I tried People service too but id does not include node id either
2 Replies
afaust
Master

Re: Create a node with an assoctiation to a user

Instead of using any specific user search API, you could use the more generic node search API to lookup the user. From that you get the node ID to use for creating associations.

panacasp
Active Member

Re: Create a node with an assoctiation to a user

Hi, I'm not sure I understand what is the generic node search API you're mentioning.

I thought you're refererring to the /query REST API, if I try /query/people i get the user parameters ( like, email and capabilities), similar to what I would get from search API and an id that is actually the username ( literally "id":"admin"). And if I try the /query/nodes i find files/folders that may contain the term in their name or contents