AnsweredAssumed Answered

[SOLVED] get workingcopy from doc JS

Question asked by thestorm on Aug 21, 2010
I got a (maybe) simple problem…

I put a doc to a workflow and check it out, so users dont edit it, till workflow is done. My problem is how to cancel the checkout … I cant see an association of document to workingcopy …

because I can't use document.cancelcheckout() since I have to use that on the working copy … but how to get the workingcopy of my document (I can check by isLocked property)

/////////

got it that way:

simple: search.findNode(bpm_package.children[0].properties["sys:node-uuid"])

complex (what I did before i found that one):

                  var noderef = bpm_package.children[0].properties["sys:node-uuid"];
                  var query = '+@\\{http\\://www.alfresco.org/model/content/1.0\\}source:'workspace://SpacesStore/' + noderef +'"';
                  var workingcopy = search.luceneSearch(query);
                  workingcopy.cancelCheckout();


//////// getting this error:

07210001 Failed to execute supplied script: 07210000 TypeError: Cannot find function cancelCheckout. (AlfrescoJS#1)

but that function is documented in 3.3 JS API …


////////// workingcopy[0] since lucene returns an array

final code (working)


               if(bpm_package.children[0].hasAspect("cm:workingcopy"))
               {
                  bpm_package.children[0].checkin("Dokument Published", true);
               }
               else
               {
                  var noderef = bpm_package.children[0].properties["sys:node-uuid"];
                  var query = '+@\\{http\\://www.alfresco.org/model/content/1.0\\}source:'workspace://SpacesStore/' + noderef +'"';
                  var workingcopy = search.luceneSearch(query);
                  workingcopy[0].cancelCheckout();
               }

Outcomes