Expand my Community achievements bar.

Whats the efficient way to write ECMA script to redirect to a provided url

Avatar

Level 4

In one of the OR step in my workflow I want to bring the annotate function for users. When the user click the annotate option I would like to redirect to the 'mnt/overlay/dam/gui/content/assets/annotate.html' appended with the payload. whats the easiest way to bring page redirect. Do I need to call any sling service from the script.

 

Thanks

4 Replies

Avatar

Community Advisor

Hi @thatsmeadarsh 

 

You may implement some custom JavaScript script which contains code to redirect url.

eg. using 

window.location and window.location.href

Regards,

Santosh

https://www.techinnovia.com/blog/

Avatar

Level 4

Thanks for your response but how do I get the payload in external JS.

Avatar

Community Advisor

Hi @thatsmeadarsh 

 

For getting payload recommended way to implement some Services or Servlet and/or pass it to the script if needed otherwise you can redirect in servlet itself.

 

Regards,

Santosh

Avatar

Level 4

Hi @SantoshSai 

I am trying to avoid the inclusion of an additional process step just for redirection. I think if I call a custom workflow process step I could get the payload from any of the available objects and possibly use a requestresponsefactory OSGI service to redirect but at the cost of an additional java class.

As per the documentation ECMA script provide these objects.

WorkItem, WorkflowSession, WorkflowData, args, sling and jcrSession.

So I can easily get the payload but I am trying to understand if redirection is possible using the sling object by calling any service.