Skip to main content

Smarter Self Service Design Widget

Patrick Bakker
Widgets

Widgets are convenient tools that help organizations add meaningful content to their 4me Self Service homepage.  One of the most used widgets, the User Name widget, has just been enhanced so that it self-adapts to the situation it is used in.

When the widget {{user_name}} is added to the HTML code of the Self Service homepage, it shows the name of the person currently logged in.  To display this name nicely, the widget creates a piece of HTML code.  This means that, until now, this widget could not be used inside another widget or inside a hyperlink.

As of now, the {{user_name}} widget has become smarter.  When it is used outside an HTML attribute, it behaves as it always has.  But when it is used inside an HTML attribute, the name of the current user is rendered without wrapping it in HTML.  If the HTML attribute in which the widget is used is href, a hyperlink, then the user name is even URL encoded.  This ensures that no unsafe ASCII characters end up in a URL.

As an example, the following code in the ‘Self Service Design’ section of the Settings console uses the {{user_name}} widget in a link pointing to the ‘Requests’ section that lists the user’s requests:

Using the widget inside an href attribute displays the user name on the Self Service homepage as a relative hyperlink pointing to ../self-service/requests.