Umang Kothari
Umang Kothari

Reputation: 3694

how to get associative child nodeRef from parent nodeRef in Alfresco

i refer this link but it does not work for me...

following code does not work :

String query = "PATH:\"/app:company_home/cm:Customer_Relationship_Management/cm:Business_Documents/cm:Orders/*\"+@crm\\:uniqueDocId:\"" + orderId + "\"";
            List<NodeRef> nodeRefs = CRMUtils.executeLuceneQuery(query);

NodeRef parentRef = nodeRefs.get(0);

List<ChildAssociationRef> childRef = AlfrescoServiceRegistry.getServiceRegistry().getNodeService().getChildAssocs(parentRef, ContentModel.ASSOC_CONTAINS, RegexQNamePattern.MATCH_ALL);

when i debugged this code i got parentRef and its correct but then following line i got empty childRef...

if you have any another solution then plz help me...

Upvotes: 0

Views: 1302

Answers (2)

Dhaval Shah
Dhaval Shah

Reputation: 61

Try the following methods of NodeService:

getSourceAssocs(NodeRef nodeRef, QNamePattern qnamePattern) or 
getTargetAssocs(NodeRef nodeRef, QNamePattern qnamePattern) 

This may solve your problem.

Upvotes: 1

togomez
togomez

Reputation: 664

What is the name of your child association? The second parameter in getChildAssocs(NodeRef nodeRef, QNamePattern typeQNamePattern, QNamePattern qnamePattern) reflects association qname. Maybe your child association qname is not ContentModel.ASSOC_CONTAINS?

Upvotes: 0

Related Questions