cancel
Showing results for 
Search instead for 
Did you mean: 

Doclib Action & Redirection

David76
Champ in-the-making
Champ in-the-making

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 :
http://localhost:8180/share/page/site/test/document-details?nodeRef=workspace://SpacesStore/NEW_NODEREF_GUID

Is it possible to redirect to the newNode in java ?

@Override
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 1

abhinavmishra14
World-Class Innovator
World-Class Innovator

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 -->
		<create-content>
<!-- 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="create.whitepaperdoc.menu.item.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="create.supportdoc.menu.item.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 https://github.com/Alfresco/share/blob/develop/share/src/main/webapp/components/documentlibrary/tool... file. You can take reference from https://github.com/Alfresco/share/blob/develop/share/src/main/webapp/components/documentlibrary/tool... 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: https://github.com/Alfresco/share/blob/develop/share/src/main/resources/alfresco/share-documentlibra...

~Abhinav
(ACSCE, AWS SAA, Azure Admin)