First Share Item

Creating your first share item

#Developer Portal , #Share , #UI Action

Andrew Barnes

4 minute read

Sharing hands

Insipration

So, you want to contribute something back to the community. You have come to the right place. Share is a great way to get handy utilities, inspiration, and help others. A little over a week ago I featured a the Add to Update Set Utility share item by Ben Hollifield. It is a very handy tool and has lots of features that I believe are not well known. One of those features is you can get a full table definition and all dependencies into the update set if you use this UI Action on the table collection record. This feature is handy, but I have a use case in which it is quite overkill.

My use case was getting all of the form layout and sections for a given table, in the event that something went wrong when moving those between instances. For some combination of events, sometimes, sections would be left out, or fields would not be quite right. Since the existing utility does already gather the needed items, I decided to just take it, and make some adjustments.

This is how I went about creating my first share item. I had a requirement and had something close, but overkill for my use case. Having used this for the past year I decided to share it back out to the community so others can see how to contribute back, even just an improvement on an existing share item. I did reach out to Ben to see if he wanted me to provide him the enhancement for incorporation to his share, or make a new one. We settled on the latter.

Creating your first share item

Since the existing item was so close, we start by installing Add to Update Set Utility. Then we make an update set to store our changes in. I opened up and inspected how Ben was handling the table definitions and object and saw that it was not easy to just insert some parameters to his action to do what I intended. This then directed me to copy the UI Action and to strip it down to just the parts and features I needed for this particular use case. Given more time and collaboration, I would instead choose to extend the framework of Ben’s utility.

Tip: When creating a UI Action, make sure to make a unique action name, if you don’t intend on overriding another action.

So, let us take a journey down to see what makes up all the components we want to get. The tables we want to look at are:

  • sys_ui_section
  • sys_ui_form
  • sys_ui_list
  • sys_ui_related_list
  • sys_ui_related_list_entry
  • sys_ui_style

So, we will query the records we want from those tables, in our script that is function addTableUI(). Then push them into the update set, function addToUpdateSet(). The magic is in using the GlideUpdateManager2() to be able to put these objects into our target update set.

That is pretty much it for our Utility. Let’s go get it into the share! So, we head over to share.servicenow.com or by visiting developer.servicenow.com and navigating to share in the menu bar. We need to login to contribute. We will click the handy Create Project button.

Create Project

Then we have just two steps to get us going. Provide title, category, product, and description. I suggest using the markdown editor.

First Step

Then we move on to providing our update set. Step 2 is to provide you update set, the version, visibility, compatibility, and release notes.

Provide update set

Then you can start pointing folks to your share item, go check this one out now!

Notes and caveats

Please note if you post an item to share publicly: Any user can see, download, and build upon the project. The project appears in the search results. You can take a share item, and adjust it, just as I have done, or you can contribute those suggestions and improvements to the original author. Please share and contribute responsibly and with code that does not violate any work or legal restrictions. Happy Sharing!


Comments