what is companyHome in alfresco NodeRef example - alfresco

Here it is told how to get a list of children of a NodeRef. Here is the code:
List<ChildAssociationRef> children = nodeService.getChildAssocs(c);
for (ChildAssociationRef childAssoc : children) {
NodeRef childNodeRef = childAssoc.getChildRef();
// Use childNodeRef here.
}
What is the parameter companyHome, what type is it and the most important is how to get it from the process?

companyHome is a root node in alfresco of files which we are creating or uploading.
Below code sample which you have given is for iterating childrens of node c, where c can be folder(space) or file in alfresco file system.In alfresco files are called content and folders are called space.
List<ChildAssociationRef> children = nodeService.getChildAssocs(c);
for (ChildAssociationRef childAssoc : children) {
NodeRef childNodeRef = childAssoc.getChildRef();
// Use childNodeRef here.
}
For retrieving company home node you can use search service and use lucene search for that. Below is link for lucene search.
https://wiki.alfresco.com/wiki/Search
For understanding search service you can use any of below link.
https://wiki.alfresco.com/wiki/Search
https://wiki.alfresco.com/wiki/Search

Related

Not able to get organization form node in alfresco

Using Alfresco Community 5.0.d and not able to get organization from node.
File: pickerresults.lib.js
Method: createPersonResult(node)
function createPersonResult(node)
{
var personObject =
{
typeShort: node.typeShort,
isContainer: false,
properties: {},
displayPath: node.displayPath,
nodeRef: "" + node.nodeRef
}
// define properties for person
personObject.properties.userName = node.properties.userName;
// defining new property for the personObject but
// but not getting any value
personObject.properties.companyname = (node.properties["cm:organization"] ? node.properties["cm:organization"] : "");
personObject.properties.companyname = (node.properties.organization ? node.properties.organization : "");
return personObject;
}
Override the pickerresults.lib.js file by copying it to location as below.
/Applications/alfresco-5.0.d/tomcat/shared/classes/alfresco/extension/templates/webscripts/org/alfresco/repository/forms/pickerresults.lib.js
how could I get organization name?
also how could I debug the node properties like logger.log is there but does not work here.
Thanks.
please try to get properties without extra "." in
node.properties.["cm:organization"]
like:
node.properties["cm:organization"]
please refer this doc link
http://docs.alfresco.com/4.0/references/API-JS-ScriptNode.html
properties
Provides access to all the properties of this node. The properties returned are accessed via an associative array. Properties of a node can be accessed in the following ways:
Example: node.properties["name"]
Example: node.properties.name
example i have tried:
var node =people.getPerson("admin");
logger.log(node.properties["cm:email"]);
logger.log(node.properties.email);

How to refer to a child nodeRef in Alfresco-share?

I am working on a custom doclib javascript. I have a folder structure which is similar to A --> B --> C where A and B have multiple children. I have the noderef of the folder A which I have found out through
"this.doclistMetadata.parent.nodeRef"
What is the easiest way to get the uri from the Node "C" while staying at Node A level? Can file path be used for this purpose?
You should get ScriptNode object (ScriptNode class):
var A = this.doclistMetadata.parent;
// or by nodeRef
// var A = search.findNode("workspace://SpacesStore/abcdefg-your-A-folder-id");
and use ScriptNode API
var C = A.childByNamePath("B/C");
print(C.name+" nodeRef: "+C.nodeRef.toString());
print(C.name+" children: "+C.childFileFolders());
It works for any ScriptNode object, virtual/smart folders too.
I think that you can use this:
For example, in the workflows, you can search for an element with the id "page_x002e_data-form_x002e_task-edit_x0023_default_assoc_packageItems". If there is more than one document associated, the value will be a comma separated list of noderefs.
var nodeRef = YAHOO.util.Selector.query("#page_x002e_data-form_x002e_task-edit_x0023_default_assoc_packageItems")[0].value;
Using the browser debug tool, you can inspect the html. As you can see in the image attached below, Alfresco stores the documents attached to the task in an hidden input. You could use YAHOO to get it.
(Source: https://stackoverflow.com/a/35257692/4337310)

DotCMIS IDocument does not give file path

I have an Alfresco 4.2 document at /Sites/swsdp/documentLibrary/Presentations/test1.txt with id workspace://SpacesStore/626216a1-5f9e-4010-a424-e2e0ec4f2663;1.0.
Here is my DotCMIS code to deal with a ChangeLog change event:
ICmisObject cmisObject = session.GetObject(
"workspace://SpacesStore/626216a1-5f9e-4010-a424-e2e0ec4f2663;1.0");
if (null != (document = cmisObject as IDocument))
{
String filename = document.ContentStreamFilename; // returns: "test1.txt"
List<String> paths = document.Paths; // returns: Empty list
}
Why is paths an empty list?
Why does it not contain /Sites/swsdp/documentLibrary/Presentations/test1.txt?
I know it is not exactly the same, but OpenCMIS documentation says this for the same method:
Returns the list of paths of this object or an empty list if this object is unfiled or if this object is the root folder
The problem is that I was using the old CMIS URL of Alfresco.
It is solved by using the new URL format:
http://<host>/alfresco/api/-default-/public/cmis/versions/1.0/atom
This isn't an answer but I can't add a comment since my rep is too low.
It works for me. I got a document's path using an Alfresco 4.2 system
btw, your code should be
String filename = document.ContentStreamFileName; //camel case
IList<String> paths = document.Paths; //IList vs List

sub folder in document library as rootNode for user

I want a sub folder within Document library as rootNode in Alfresco Shave 4.2
For Example In Document Library the folder path is Documents > XYZ > User1. When user accesses Document Library by default the content in Documents > XYZ > User1 should be displayed instead of content in Document. If we customize rootNode property from below code which is part of toobar.get.js it should work..I replaced rootNode with XYZ and it works. But rootNode="XYZ/User1" does not work
Not sure how to speciy the sub folder ?
var docListToolbar = {
id: "DocListToolbar",
name: "Alfresco.DocListToolbar",
options: {
siteId: (page.url.templateArgs.site != null) ? page.url.templateArgs.site :"",
rootNode: toolbar.rootNode != null ? toolbar.rootNode : "",
hideNavBar: Boolean(toolbar.preferences.hideNavBar),
googleDocsEnabled: toolbar.googleDocsEnabled,
repositoryBrowsing: toolbar.rootNode != null,
useTitle: (useTitle == "true"),
syncMode: toolbar.syncMode != null ? toolbar.syncMode : "",
createContentByTemplateEnabled: model.createContentByTemplateEnabled,
createContentActions: model.createContent
}
};
model.widgets = [docListToolbar];
since edit online is not present in My Files we created a cutom site in Alfreso Share as a custom My Files section.
Maybe it's a bit late but I would suggest to create a custom site page, almost the same as document library, but with changed root node. And then you can easily replace Document Library page with custom one in site settings.
I have a quite nice example here: http://streetturtle.ninja/jekyll/update/2014/10/23/alf-custom-doclibrary-site-page/. It is almost the same as you want, but the root node changes according to the logged user.

Batch Export Forms from AX 2009

I'm currently working on a system that will export all the nodes from my AX 2009 AOT to individual XPO files, for the purpose of tracking changes in a central version control repository. I'm having a fair amount of luck, but for some reason I cannot get the Forms or Data Sets node to export at all.
This is my current code set:
private void export(str parentNode)
{
TreeNode node, parent;
str folderName;
Set permissions = new Set(Types::Class);
;
folderName = exportBaseDir + parentNode;
permissions.add(new FileIoPermission(folderName, "r"));
permissions.add(new InteropPermission(InteropKind::ClrInterop));
CodeAccessPermission::assertMultiple(permissions);
//Create Filesystem Folder if needed
if (!WinApiServer::pathExists(folderName))
System.IO.Directory::CreateDirectory(folderName);
CodeAccessPermission::revertAssert();
parent = TreeNode::findNode(parentNode);
if (parent)
node = parent.AOTfirstChild();
else
warning(strfmt("Could not parse node: %1", parentNode));
while (node)
{
this.exportNode(node);
node = node.AOTnextSibling();
}
}
When I call export(#"\Forms"); or export(#"\Data Sets"); I get a "Could not parse node" message, meaning the TreeNode::findNode() didn't resolve correctly. Running it on any other node (such as Classes) does not have this issue. This also only happens when it is run in a Batch -- running it with the client (with the CodeAccessPermission parts removed) will export all nodes as expected.
Is there something that would prohibit Forms and Data Sets from being accessed from within a Batch? If so, what can I do to access those nodes?
As far as I can tell it's a server/client issue/bug. The easy solution would be to create this method on your class:
client static TreeNode clientTreeNode(str _path)
{
return TreeNode::findNode(_path);
}
Then in your code, below the parent = TreeNode::findNode(parentNode); line, put:
parent = parent ? parent : YourClassHere::clientTreeNode(parentNode);
And that should solve your issue. You'll have a bit of digging to do in order to find out why it doesn't work on the server tier if you just must know.

Resources