Zoho Creator: Redirect to the Same Record After Submitting
By default, your Zoho Creator App will redirect you to the related report of a form after submitting or updating a form record. In my case, I wanted to be able to submit or update a form and redirect right back to the same form record. Zoho Creator does not provide an easy way to do this via the form builder and so we must resort to some Deluge.
Using the openURL task and the on success workflow event action we can have our application redirect to any website we’d like after a successful submit or update on a form.
To do this, you’ll want to create a new workflow action for your form. Select Deluge Script as your action type and On Success as your event.
You’ll only need one line of Deluge code to tell the app where to redirect to via the Open URL task.
openUrl(<url>, <window>);
The Open URL task take two parameters, the first specifies what URL you’d like to redirect to and the second to specifies in which window you’d like to open the URL. Defining the URL that redirects back to the same record is the tricky part, but specifying the window should be straight forward. Your options for window are as follows:
- same window
- new window
- parent window
- popup window (to be followed with “height=,width=” as a third parameter)
- iframe (to be followed with the frame name as a third parameter)
To redirect back to the same form record we’ll have to build a URL that uses several application and form specific names. Here’s the basic formula:
"https://app.zohocreator.com/<zoho_account_name>/<app_link_name>/#Form:<form_link_name>?viewLinkName=<report_link_name>&recLinkID=" + input.ID
You’ll need to replace all <variables>. The best way to find your <app_owner_name>, <app_link_name>, and <form_link_name> is access the form build for the form you are trying to redirect back to. The URL for the form build will include all three of these variables. The <report_link_name> is the link name of the main report for the same form. You’ll need to include the <report_link_name> if you want the app sidebar to appear. Lastly, we need to include the record ID in the URL by referencing the current record ID via input.ID.
OK, that’s a lot to swallow, so here’s a full example. You’ll be replacing the bold parts.
openUrl(“https://app.zohocreator.com/owner-name/app-name/#Form:Form_Link?viewLinkName=Report_Link&recLinkID=” + input.ID,”Same window”);
Let me know in the comments if you were able to implement this bit of code into your app successfully or if you ran into some trouble along the way. I’d also be interested to hear about some other creative uses for the Open URL task.