Quantcast
Channel: SCSMfaq.ch » Layout
Viewing all articles
Browse latest Browse all 10

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

$
0
0

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



Viewing all articles
Browse latest Browse all 10

Latest Images

Trending Articles





Latest Images