Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
Bedrock Mission!

Learn more

View all

Sign in to view all badges

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

thatsmeadarsh
Level 3
Level 3

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

2 Replies
SantoshSai
Level 5
Level 5

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/

thatsmeadarsh
Level 3
Level 3

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

SantoshSai
Level 5
Level 5

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

thatsmeadarsh
Level 3
Level 3

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.