This gives me a PSContentNode, but no local fields are included in the properties, only the system fields. Is there a better way to do this or should I just be resorting to a JSR query to access the fields?
This gives me a PSContentNode, but no local fields are included in the properties, only the system fields. Is there a better way to do this or should I just be resorting to a JSR query to access the fields?[/QUOTE]
Thanks, Nate. That makes sense about the revision in the Guid.
Unfortunately, in my current context, I only have the sys_contentid. I suppose I could run my original code and get the current revision from the node, then run it again inserting that revision.
I did have some success using psoQueryTools.executeQueryNodes. I’m not sure if this is a particularly efficient way, but it does the job. I created this velocity macro, which may be useful to someone:
## Runs Query to get a content node from a content id. Returns Node as "$myNode" for use in Velocity template
## Params $myItemId: sys_contentid, $myContentType: name of content type. Example: #getnodefromid ("1234" "rffGeneric")
#macro(getnodefromid $myItemId $myContentType)##
#set ($myNodeQuery = "select rx:sys_contentid from rx:" + $myContentType + " where rx:sys_contentid='" + $myItemId + "'")##
#set ($myNodeResult = $user.psoQueryTools.executeQueryNodes($myNodeQuery,1,null,null))##
#set ($myNode = $myNodeResult.nextNode())##
#end##
You’d have to test the performance of it compared to the query, but it may be better performing to read the revision property of the content node loaded with no local fields, and then create a second guid with the revision, and then reloading the the node with that Guid to get the local fields.
Everything except the local field data will be cached so the 2nd request should be pretty quick.
[QUOTE=junwin;20932]Thanks, Nate. That makes sense about the revision in the Guid.
Unfortunately, in my current context, I only have the sys_contentid. I suppose I could run my original code and get the current revision from the node, then run it again inserting that revision.
I did have some success using psoQueryTools.executeQueryNodes. I’m not sure if this is a particularly efficient way, but it does the job. I created this velocity macro, which may be useful to someone:
## Runs Query to get a content node from a content id. Returns Node as "$myNode" for use in Velocity template
## Params $myItemId: sys_contentid, $myContentType: name of content type. Example: #getnodefromid ("1234" "rffGeneric")
#macro(getnodefromid $myItemId $myContentType)##
#set ($myNodeQuery = "select rx:sys_contentid from rx:" + $myContentType + " where rx:sys_contentid='" + $myItemId + "'")##
#set ($myNodeResult = $user.psoQueryTools.executeQueryNodes($myNodeQuery,1,null,null))##
#set ($myNode = $myNodeResult.nextNode())##
#end##