Visual Studio Authoring Extensions (VSAE) – Part 3: Creating Views by using Snippet Templates

VSAE offers multiple options to create views. You could use the View template or an empty Management Pack Fragment template. For this example however, I decided to use a snippet template to demonstrate how this can be used to create your own templates for your needs. It is indeed very powerful and can save you lots of time for repetitive tasks.

Part 1 – VSAE Part 1: Creating a new CI Class
Part 2 – VSAE Part 2: Creating a Folder with a custom Image
Part 3 – VSAE Part 3: Creating Views by using Snippet Templates (this post)

First, add a new Snippet Template to your project. This will become your code blue print for a specific function like views, folders etc.

image

The template will show some code. The idea behind is, that you can replace hard coded information with place holders that are later configured in the GUI. There are three different place holders available:

  • #text# –> This will be replaced by a value that is entered in the GUI later (e.g. the name of a new view)
  • #alias# –> This can be used to reference to another MP (e.g. System)
  • #choice# –> This allows to select from a list of predefined values (e.g. Accessibility = Public/Internal)

image

Check the sample code first, then delete it an paste your own code. I quickly created a view in the SCSM console, saved it to a MP, then exported it. This is more or less the code you can paste here. After the code is pasted and the needed tidy up has been done, remove the hard coded information and use the mentioned place holders.

image

image

In this example MP, the view, the class and the parent folder for the view live in the same MP, therefore I removed the referencing to other MPs from the code.

After saving the Snippet template, we can now use in together with another snippet. Add a new Snippet to the project, then select your prepared snippet

image

image

image

Now we are ready to add a new view using the GUI that uses the snippet template in the background. A cool thing is, that you can add views by using CSV Import which allows you to create hundreds of objects within minutes.

image

Now build and deploy the MP. The new view should be visible in the SCSM console. If needed, add some cool images. as I already went through the needed steps in this series, I will not go into any details again. Please read the relevant posts.

image

Nice! Now, in a perfect world it would make sense to separate classes from views, but in this example I used a single sealed Management Pack for everything. Stay tuned for the next part!

Cheers
Marcel

This entry was posted in SCSM and tagged , , , , , , . Bookmark the permalink.

5 Responses to Visual Studio Authoring Extensions (VSAE) – Part 3: Creating Views by using Snippet Templates

  1. Pingback: Visual Studio Authoring Extensions (VSAE) – Part 1: Creating a new CI Class | SCSMfaq.ch

  2. Pingback: Visual Studio Authoring Extensions (VSAE) – Part 2: Creating a Folder with a custom Image | SCSMfaq.ch

  3. Chuck Herrington says:

    this is a great intro into creating management packs. One thing though, is there somewhere where I can download the finished project? I ask specifically because when I try to follow the example my view isn’t coming out quite the same and I suspect it might be because https://scsmfaq.files.wordpress.com/2013/01/image37.png is cut off and i cant see the end of the column definition.

  4. thorstengsxr says:

    Sorry Marcel

    The Screenshots are not complete what is with the querry parameter and with the DisplayMemberbinding. I think that this parameters are verry importend.

    regards Thorsten

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s