Understanding DataTypes and Taking Advantage of Them

Understanding DataTypes and Taking Advantage of Them
blollich's picture

DataTypes are a great part of Workflow Solution, as long as you understand them and use them to your advantage. Failing to understand datatypes can lead to frustration and agony, so save yourself the pain and get to know them up close and personal.

The Altiris datatypes are documented for us already at: Altiris Component Data Types

To get an idea of what a datatype is and how it can be used we'll create the beginnings of a simple software request portal. We'll use two datatypes, Service Desk Contact and Service Desk Asset.

First, we create a web forms project. We drag the GetCurrentUser component into the design workspace. This component will get the NTid of the person browsing our software request portal. Next we pass that handy information into the Find Service Desk Contact component.

Tip: GetCurrentUser requires a few things to be set in order to work correctly. In order to use it in IIS you need to set it to HttpContext. Your web site needs to use Windows Authentication and the web.config file in this applications virtual directory needs to have Authentication=Windows.

Keep in mind that the debug web server does not use Windows Authentication, so this component will not function as it does in IIS. To get around this, I hard code an NTid when I'm debugging and remove it for production.

Here's what the project looks like so far:

The Find Service Desk Contact component will query the helpdesk and return its results into a variable named foundContacts. The KEY here is that foundContacts is a Service Desk Contact datatype. By reading the article referenced above, we know that this variable will contain a contact email, contact id, contact name and contact resource guid for each match of the NTid we passed into the component.

Here is what the Find Service Desk component looks like:

The trick is figuring out what datatype the component created, so you can use the datatype to your advantage. An easy way to do this is to right click a component (the END component in this example) further down the process and choose Browse Data. This allows you to see the variables you've created thus far. To view datatypes simple check the Show Type Name box. In this example we see the datatype of foundcontacts is ServiceDeskContact.

Now that you've gotten a glimpse into datatypes, lets see how we can use them effectively.

We've got the contact info for our software request form, now lets create a dropdown list of assets associated with the contact requesting the software. Simply add the Get Service Desk Assets for Contact component into the flow.

It's properties look like this:

Here we've input the contactid (part of the ServiceDeskContact datatype) into the component and it output a variable called AssetListForContact. Using the Browse Data trick we learn that this variable's datatype is ServiceDeskAsset.

Now we will create a software request web form to present to the user. More importantly, we will use the ServiceDeskAsset datatype and save ourselves some work.

Create the webform and use the asciimergelabel component to add the contact name and contact email to the form. Then add some labels for these two fields.

Next add a dropdown box. Set its type to ServiceDeskAsset. This datatype is located under Symantec.Workflow.Core.

Now the display field list is populated for us. Choose Name to display the names of computers in the dropdown list. Choose the AssetListforContact as the list of Items. Because we defined this dropdown list as a ServiceDeskAsset datatype, we will only see variables that are of this same type, ie AssetListforContact. The cusPickedAsset variable we create with this dropdown will be of type....ServiceDeskContact.

Here is what the component looks like:

Here is the web form:

The datatype in this case allowed us to display a friendly list of computer names that the user could select from. The user would then select a single name to install the software on. Our variable would be populated with the name, department, location, GUID, Type_Lookup_Value and ID of the computer the user selected. The key here is that we didn't have to do any fancy lookups to get this extra information, it was part of the datatype, we just had to setup our dropdown box correctly to use it.

Here is what Browse Data says:

We could have set the datatype on the dropdown box to text and still displayed the asset names in the list. However, then we would have had a variable with an asset name in it, and no GUID. We will need the GUID to push software to the machine, so really the variable is useless without some other logic that retrieves it for us. This translates to more work for us that really wasn't necessary.

Hopefully, this article gives you an insight into datatypes and how to use them to your advantage.

3.72973
Average: 3.7 (37 votes)
Syndicate content