Doclib Action & Redirection

Showing results for 
Search instead for 
Did you mean: 
Member II

Doclib Action & Redirection

Hi Everyone !

I work with this alfresco version : All-In-One (AIO) project for SDK 4.0
I have created a new Doclib Action that create a new file ! (so with new nodeRef !)
My problem is : in alfreso portal, i always stay on the current nodeRef and i would like redirect to the new nodeRef :

Is it possible to redirect to the newNode in java ?


protected void executeImpl(Action action, NodeRef actionedUponNodeRef) {

	if (serviceRegistry.getNodeService().exists(actionedUponNodeRef) == true) {

		NodeService nodeService = serviceRegistry.getNodeService();

		try {
			NodeRef newNode = Tools.updateDocument(
					nodeService, serviceRegistry.getFileFolderService(),
					actionedUponNodeRef, propsNewDoc, propsOldDoc);
			//TODO redirection to newNode 
		} catch (Exception e) {
			throw new WorkflowException(e.getMessage());



Thank you for your answer !

1 Reply

Re: Doclib Action & Redirection

I don't think this can be achieved with only java, you have to make use of javascript function in combination or just use javascript function. it is sufficient to perfrom the operation. 

Examples of creating node:


<config evaluator="string-compare" condition="DocumentLibrary">
		<!-- Create custom type nodes -->
<!-- METHOD 1: using ootb create-content function, it takes you to a new page and upon saving the node it lands on doclib --> <content id="whitepaper-doc" label="" icon="whitepaper" type="pagelink"> <param name="page">create-content?destination={nodeRef}&amp;itemId=demo:whitePaper&amp;mimeType=text/plain</param> </content>
<!-- METHOD 2: using a custom function e.g. onNewObject , upon node creation you can grab the noderef and redirect --> <content id="support-doc" label="" icon="supporting-doc" type="javascript"> <param name="function">onNewObject</param> <param name="type">demo:supportingDoc</param> </content> </create-content> .... </config>

For custom function you have to extend the file. You can take reference from function and create a custom one for your custom nodes and 'onCreateSuccess' callback add redirect logic at the end when node creation is successful. 

METHOD 1: using ootb create-content function by default takes you to newly created node if you would like to prefer. you can find more examples here:

(ACSCE, AWS SAA, Azure Admin)