“Do. Or do not. There is no try.”
— Yoda
I have been playing around a lot lately with my hacked up Service Portal Data Table widget, but just about everything that I have done has been centered around some kind of Task. I have been wanting to do something a little different, so I decided that I would use my breadcrumbs widget, my content selector, and my custom data table to create a User Directory portal page. I started out by creating a new page called user_directory and opening it up in the Portal Designer.
First I dragged a 12-wide container over into the top of the page and then dragged the breadcrumbs widget into that. Then I dragged over a 3/9 container and put the content selector into the narrow portion and the data table into the wider portion. That gave me my basic layout.
Since this was going to be a list of Users on the portal, I decided that the page to which we will link should be the user_profile portal page, so I updated the table options to link to that page, and to add a user icon as the glyph.
We also need to update the content selector widget options, but it is going to ask for a configuration script, which we have not built just yet, so let’s do that now. For this, we can use the new Content Selector Configuration Editor to create a new configuration script called UserDirectoryConfig.
For this initial version of the directory, we will have two Perspectives: 1) a general public perspective for all authenticated users, and 2) a user administration perspective for those with the authority to update user records. We will also define 3 States: 1) active users, 2) inactive users, and 3) all users. For each Perspective, we will define a single Table, the User (sys_user) table.
For all of the public states, we will specify the following field list:
name,title,department,location,manager
Since I do not want regular users looking at inactive users, I used the following filter for both the Active state and the All state:
active=true
For the Inactive state, which I wanted to always come up empty, I used this:
active=true^active=false
For the admin states, we will drop the manager and add the user_name, and for the All state, we will also add the active flag:
user_name,name,title,department,location,active
And of course the filters for the admin states are all pretty self explanatory, so there’s no need to waste any space on those here. One little extra thing that I did want to add to all of the admin states, though, was an Edit button. Clicking on the user_name will get you to the user_profile page, but if you want to edit the user information, you need to go the form page, so I added a button for that purpose to all three of the admin states.
After completing the configuration, saving the form produced the following configuration script:
var UserDirectoryConfig = Class.create();
UserDirectoryConfig.prototype = Object.extendsObject(ContentSelectorConfig, {
initialize: function() {
},
perspective: [{
name: 'everyone',
label: 'Public',
roles: ''
},{
name: 'admin',
label: 'User Admin',
roles: 'user_admin,admin'
}],
state: [{
name: 'active',
label: 'Active'
},{
name: 'inactive',
label: 'Inactive'
},{
name: 'all',
label: 'All'
}],
table: {
everyone: [{
name: 'sys_user',
displayName: 'User',
active: {
filter: 'active=true',
fields: 'name,title,department,location,manager',
btnarray: [],
refmap: {},
actarray: []
},
inactive: {
filter: 'active=true^active=false',
fields: 'name,title,department,location,manager',
btnarray: [],
refmap: {},
actarray: []
},
all: {
filter: 'active=true',
fields: 'name,title,department,location,manager',
btnarray: [],
refmap: {},
actarray: []
}
}],
admin: [{
name: 'sys_user',
displayName: 'User',
active: {
filter: 'active=true',
fields: 'user_name,name,title,department,location',
btnarray: [{
name: 'edit',
label: 'Edit',
heading: 'Edit',
icon: 'edit',
color: '',
hint: '',
page_id: 'form'
}],
refmap: {},
actarray: []
},
inactive: {
filter: 'active=false',
fields: 'user_name,name,title,department,location',
btnarray: [{
name: 'edit',
label: 'Edit',
heading: 'Edit',
icon: 'edit',
color: '',
hint: '',
page_id: 'form'
}],
refmap: {},
actarray: []
},
all: {
filter: 'true',
fields: 'user_name,name,title,department,location,active',
btnarray: [{
name: 'edit',
label: 'Edit',
heading: 'Edit',
icon: 'edit',
color: '',
hint: '',
page_id: 'form'
}],
refmap: {},
actarray: []
}
}]
},
type: 'UserDirectoryConfig'
});
Now we can go back into the Page Designer and edit the content selector widget options to specify our new configuration script.
Now all that is left to do is to go out to the Service Portal and give it a go. Let’s see how it comes out.
I like it! I clicked around and tried a few things. Overall, I think it came out pretty good, but I did come across one flaw already: clicking on someone’s department or location will take you to the user_profile page and get you a nasty error message because there is no user on file with the sys_id of a department or location. That’s not good. That also brings up an interesting point: I don’t really want to send regular users to the form page for departments or locations, either. I need to find a more appropriate destination for those links. I guess I won’t be wrapping this all up in a bow today after all. I’ll have to give this one some thought, so this looks like an issue that we will have to take up next time out.