Episode #9 — Adding redirects to keep your users where they want to be
Welcome back, Low Coders! We’ve come so far together over the last 8 episodes! Look at what we can now do using the Skedulo Pulse Platform:
- Create new objects
- Update the view and edit pages of objects
- Edit records straight from your list view
- Add images to pages for visual spectacle
- Add relationships between object
- Put tabs on your pages
- Add filters to your tabs
- Pre-populate data for your users
You’ve reduced clicks, made pages beautiful, and made sure your users have an easier time at work, each and every day. No more will there be a cry of ‘Help me, you’re my only hope’! You have done the Kessel Run in 12 parsecs! In this episode we’re going to tackle adding a redirect to the Fleet Create page which will return the user back to the Aircraft View page after they add a Fleet Assignment record. This will again save your users a few extra clicks, which adds up to a better all-round experience.
To add this redirect in, you simply navigate to the Fleet Create page and add the following code snippet underneath {% set validation_schema=”fleetCreate” %}
{% set back_url = _.host.buildPlatformUrl('aircraft-view?uid=' + _.queryParams.Aircraft + '&selectedtab=fleet-assignments') %}
Breaking down this snippet, you can see we’re setting the Back URL
to redirect the Aircraft View
page of the aircraft associated with the Fleet
record being created, and landing on the Fleet Assignments
tab. This will work perfectly, if the only way to create a Fleet record is from the Aircraft View
page, passing through the Aircraft ID
as a parameter.
In our scenario, we would also want to be able to create a Fleet
record from the Account
page, as well as from the list view. With the above snippet in place, if the Fleet
record was created from any place other than Aircraft
record, you’d receive an error (as there would be no Aircraft ID
to send to the URL). There are a couple of ways we can fix this. One way is to include additional options for the return URL using some IF
statements.
This works well if your data model is pretty static, and you’re unlikely to add new ways to add Fleet records in the future. Another way, which is more dynamic and allows for greater flexibility in the long run is to add both return URLS and return IDs as parameters, meaning that should you need to add additional options, these can be handled through the button, rather than updating the Create page with more and more IF
statements as time goes by.
We’ll cover off the IF
statement option first. One thing to remember is that if you want to redirect your users back to a specific record (i.e. a specific Account) then you will need to include the Account ID
as a parameter being passed through to the Fleet
page. (If you can’t remember how we did this, it was back in Episode 8)
When using an IF
statement, it’s important to think about the order of your statements. In our scenario, we want to direct users to the Aircraft
or Account
record they were on prior to creating the Fleet
record, or if creating the Fleet
record from somewhere else, return them to the Fleet List
view. To do this, we want to put the default return URL as the list view.
After that, we can then redirect to the Aircraft
page if the Aircraft UID
is sent as a parameter, or to the Account page if the Account UID is sent as a parameter.
{% set back_url = _.host.buildPlatformUrl('fleet-list') %}
{% if _.queryParams.Account != null %}
{% set back_url = _.host.buildPlatformUrl('account-view?uid=' + _.queryParams.Account + '&selectedtab=fleet-assignments') %}
{% endif %}
{% if _.queryParams.Aircraft != null %}
{% set back_url = _.host.buildPlatformUrl('aircraft-view?uid=' + _.queryParams.Aircraft + '&selectedtab=fleet-assignments') %}
{% endif %}
This code snippet will check to see if either the Account UI
D or the Aircraft UID
is sent as a parameter — if it is, then the user will be redirected to the appropriate page (and the right tab on the page — fancy!). If there is no UID sent, the user will go back to the default page, which in our case is the list view. Neat!!
To make the solution more dynamic, we can set the Return URL
and the Return UID
as parameters in the Fleet Create
page, and then send these parameters through the button initiating the create record (in our case the Add Fleet Assignment
button on the Aircraft View
page).
Let’s start with setting the dynamic parameters on the Fleet Create
page, shall we? Underneath {% set validation_schema=”fleetCreate” %}
we want to add in the below snippet (if you’ve followed along above, you’ll need to remove your IF
statements and the other Back URL
statements).
{% set back_url = _.host.buildPlatformUrl(_.queryParams.retPage + '?uid=' + _.queryParams.retUID) %}
This snippet says that the return page and return UID
will be sent as parameters. Now these values can be sent from any button through the whole system! For this to work, we need to update the button (or buttons) that actually sends the parameters to the Fleet Create
page — we’ll work through the Add Fleet Assignment button on the Aircraft View page, but this should also be done through the Add Fleet Assignment button on the Account View
page (so our users can create an Assignment from either place and still end up back in the right spot when they’re done!)
In the Aircraft View
page, navigate to the section where we have the button to Add Fleet Assignment in the Fleet Assignment
tab. We want to add in the return URL and the UID
of the record we want our users to return to — this will then be passed through to the Fleet Create page!
<platform-component
package-name="recordpage"
name="RecordTemplate"
template="{{ '
<sp-link
href="{{_.host.buildPlatformUrl("fleet-create?retPage=aircraft-view&Active=True&Aircraft="+ _.queryParams.uid+ "&retUID=" + _.queryParams.uid)}}">
<sp-button
button-type="secondary">
Add Fleet Assignment
</sp-button>' }}">
</platform-component>
Amazing!!
All the tips and tricks we’ve covered in this series can be applied throughout your Skedulo tenant. The only limit is your imagination. Think your account page looks a little bland? Add some images. List view looks a bit grey? Add some colour and icons to engage your users. Save clicks where you can, and your users will be singing your praises all day long.
Thank you for following along in this crazy journey — the skills you now have in your arsenal will set you up to conquer the galaxy!
As always, if you have questions, reach out to us via the comments below or on Twitter @SkeduloDevs.