Saturday, March 8, 2014

SCSM 2012 - Exploring Worflow in Sealed MP

Few days ago, I posted a question to TechNet to ask around if anyone come across any way to explore or see what is inside a sealed MP in SCSM 2012. My thread SCSM 2012 - Workflow customization. Thank you so much for those who answer my post.

For those who has been dealing with SM Authoring Tool, I believe you are familiar in Extending the Class and Form. But do you notice you cannot copy or extend the Workflow from an existing sealed MP ?

Below screen capture is from SM Authoring Tool showing the contents of Service Manager Change Management Library (a Sealed MP). What if we want to see how does the workflow look like ?


I come across a very good blog that tells how we could access to a sealed MP through SQL Queries.

DISCLAIMER: USING SQL QUERIES TO ACCESS SCSM CONTENT IS NOT SUPPORTED AND RECOMMENDED BY MICROSOFT. BE SURE YOU ARE WIDE AWAKE WHEN YOU ARE DOING THIS.

At the SCSM Management Server, launch MS SQL Management Studio. Connect to Database Engine and execute the query below

#SQL Query
Use ServiceManager
select MPName, CONVERT(xml,MPXML) from ManagementPack order by MPName
 

Now we can locate the MP that we want and noticed the column next to MP Name. Those are the Management Pack in XML !!! Click on it and you will get the entire MP contents in XML.


Now I can take a closer look on the Activity Status Changed workflow, and it looks as below


Activity Status Changed Rule

<Rule ID="ServiceManager.ChangeManagement.ActivityStatusChangedRule" Enabled="true" Target="System.WorkItem.ChangeRequest.InternalWorkflowTarget" ConfirmDelivery="true" Remotable="true" Priority="Normal" DiscardLevel="100">
        <Category>System</Category>
        <DataSources>
          <DataSource ID="DS" TypeID="Subscriptions!Microsoft.SystemCenter.CmdbInstanceSubscription.DataSourceModule">
            <Subscription>
              <InstanceSubscription Type="$MPElement[Name='CoreActivity!System.WorkItem.Activity']$">
                <UpdateInstance>
                  <Criteria>
                    <Expression>
                      <Or>
                        <Expression>
                          <And>
                            <Expression>
                              <SimpleExpression>
                                <ValueExpression>
                                  <Property State="Pre">$Context/Property[Type='CoreActivity!System.WorkItem.Activity']/Status$</Property>
                                </ValueExpression>
                                <Operator>Equal</Operator>
                                <ValueExpression>
                                  <Value>$MPElement[Name="CoreActivity!ActivityStatusEnum.Active"]$</Value>
                                </ValueExpression>
                              </SimpleExpression>
                            </Expression>
                            <Expression>
                              <SimpleExpression>
                                <ValueExpression>
                                  <Property State="Post">$Context/Property[Type='CoreActivity!System.WorkItem.Activity']/Status$</Property>
                                </ValueExpression>
                                <Operator>NotEqual</Operator>
                                <ValueExpression>
                                  <Value>$MPElement[Name="CoreActivity!ActivityStatusEnum.Active"]$</Value>
                                </ValueExpression>
                              </SimpleExpression>
                            </Expression>
                          </And>
                        </Expression>
                        <Expression>
                          <And>
                            <Expression>
                              <UnaryExpression>
                                <ValueExpression>
                                  <Property State="Pre">$Context/Property[Type='CoreActivity!System.WorkItem.Activity']/Status$</Property>
                                </ValueExpression>
                                <Operator>IsNull</Operator>
                              </UnaryExpression>
                            </Expression>
                            <Expression>
                              <SimpleExpression>
                                <ValueExpression>
                                  <Property State="Post">$Context/Property[Type='CoreActivity!System.WorkItem.Activity']/Status$</Property>
                                </ValueExpression>
                                <Operator>Equal</Operator>
                                <ValueExpression>
                                  <Value>$MPElement[Name="CoreActivity!ActivityStatusEnum.Ready"]$</Value>
                                </ValueExpression>
                              </SimpleExpression>
                            </Expression>
                          </And>
                        </Expression>
                      </Or>
                    </Expression>
                  </Criteria>
                </UpdateInstance>
              </InstanceSubscription>
              <!--<StartWatermark>1</StartWatermark>-->
              <PollingIntervalInSeconds>10</PollingIntervalInSeconds>
              <BatchSize>100</BatchSize>
            </Subscription>
          </DataSource>
        </DataSources>
        <WriteActions>
          <WriteAction ID="WindowsWorkflow" TypeID="Subscriptions!Microsoft.EnterpriseManagement.SystemCenter.Subscription.WindowsWorkflowTaskWriteAction">
            <Subscription>
              <WindowsWorkflowConfiguration>
                <AssemblyName>Microsoft.EnterpriseManagement.ServiceManager.ChangeManagement.Workflows</AssemblyName>
                <WorkflowTypeName>Microsoft.EnterpriseManagement.ServiceManager.ChangeManagement.Workflows.ActivityStatusChangedWorkflow</WorkflowTypeName>
                <WorkflowParameters>
                  <WorkflowParameter Name="InstanceId" Type="guid">$Data/BaseManagedEntityId$</WorkflowParameter>
                </WorkflowParameters>
                <RetryExceptions />
                <RetryDelaySeconds>11</RetryDelaySeconds>
                <MaximumRunningTimeSeconds>7200</MaximumRunningTimeSeconds>
              </WindowsWorkflowConfiguration>
            </Subscription>
          </WriteAction>
        </WriteActions>
      </Rule>

Monday, March 3, 2014

Extending Service Request Form - Part 1 (Extending SR Class)

Throughout my experiences in implementing Service Manager 2012 (SCSM) for enterprise organisation, one of the challenge that repeat itself in each project is Service Request Fulfilment (SR).

For those who has come across the SR module of SCSM 2012, SCSM 2012 SP1 and SCSM 2012 R2, I am sure you will find that the SR Form out-of-box is nothing to fancy about. Instead you may find it very constraint and you barely can make anything out of it. Say for scenario below that you achieve which I am quite sure you could not achieve these

Scenario 1: Request Offering to Create AD Account
IT People always as how can I delegate this to HR Department (maybe) and there can request AD account through SSP. The challenge is how do you ask and map information such as First Name, Last Name, Middle Name, Proposed Username and etc. Well, asking the HR to use the "Description" box maybe a solution, but often they find it not practical.

Scenario 2: Request Offering to Request VM
Again, how could the IT Department allow the Business Unit to request for a virtual server. While the IT infrastructure is operating on a Private Cloud Concept, there is no practical way for user to request a VM with specific specification such as Processor, Memory, Operating System require.

Most of the people I come across they find it SR module of SM is not user friendly as why "M" does not consider all of this.

Well, it time to look from another angle. Service request is a very subjective module of all. You can have... ALL SORT OF REQUESTS...literally. To think about this, how could we expect "M" to make all sort of forms that could suit all of us. Of course "M" don't do that. That's where we come into picture, to understand user requirement and EXTEND the existing SR form.

Extending the SR form simply means to introduce more "field" to the form to capture the require information. This field is then use in Request Offering and publish through SSP as and interface to end user.

The rest of this topic explain how to extend the SR form to make request such as "Request VM" through SR possible and more practical.

Requirement
1. Service Manager 2012 - Management Server (of course)
2. Service Manager 2012 - Development Management Server (Good to have)
3. Service Manager console
4. Service Manager Authoring Tool
5. Basic understanding of SCSM Projection, Class and Management Pack Components
6. Knowledge in Visual Studio and programming is added advantage (no kidding)

Extending Service Request Form Series
Extending Service Request Form - Part 1 (Extending SR Class)
Extending Service Request Form - Part 2 (Extending SR Form)
Extending Service Request Form - Part 3 (Customizing the MP)

Extending Service Request Class

1. Install the SM Authoring Tool either on the Management Server or on your desktop.

2. Launch the SM Authoring Tool. Click on "New" to create a new Management pack for SM.


3. I created the MP with name "CMY_SRF_Extension_RequestVM"


4. Review the new MP created


5. At the Class Browser pane, select System Work Item Service Request Library and search for Service Request class. Right-click the class and select View.


6. Back to the Management Pack Explorer, you will see Service Request class listed under the sealed MP of System Work Item Service Request Library. Right-click Service Request class and select Extend class.


7. Review the changes will be saved in the MP that we have created earlier, click OK.


8. Lets name the extended class.


9. In the result pane, click Create property. We name the propoerty as CMY_SRF_Req_VM_Proc. This is the property we create to capture information of VM Processor Count in request.


10. Right-click the property create and select Edit data type.


11. Select List.


 12. Select the List that will be use by this property.


13. Repeat step 11 to 12 for all the items.


We are now done with the SR Class extension. Next we will focus on extending SR Form.

Sunday, March 2, 2014

Importing Change Record (with Activity) to Service Manager 2012 using CSV

A recent project that I actively involve, require us to import their existing Change Record (CR) into SCSM 2012 SP1. Like some the organisation out there, the IT department has to retain these information for reference and auditing purposes. Instead of keeping this information (in Excel spreadsheet), it is always good to have this to put into once place. So how do we achieve that ?

If you come across my previous blog on Importing Data (Incident Record) to Service Manager 2012 using CSV - Part 1, then you should have have an idea on
1. SCSM Projection
2. SCSM Type of Class
3. Apendix A (file)

The complication with a typical CR is that you have Activity (or sometime nested Activity) to deal with. I am going to show how can we import a CR with single Activity from CSV.
<CSVImportFormat>
    <Projection Type="System.WorkItem.ChangeRequestProjection">
        <Seed>
            <Class Type="System.WorkItem.ChangeRequest">
     <Property ID="Id" />
     <Property ID="Reason" />
              <Property ID="Notes" />
              <Property ID="Status" />
              <Property ID="Category" />
              <Property ID="Priority" />
              <Property ID="Impact" />
              <Property ID="Title" />
              <Property ID="Description" />
              <Property ID="CreatedDate" />
              <Property ID="ScheduledStartDate" />
              <Property ID="ScheduledEndDate" />
              <Property ID="ImplementationPlan" />
              <Property ID="RiskAssessmentPlan" />
              <Property ID="BackoutPlan" />
              <Property ID="TestPlan" />
              <Property ID="PostImplementationReview" />
              <Property ID="RequiredByDate" />
              <Property ID="Risk" />
<Property ID="ImplementationResults" />
              <Property ID="Area" />
              <Property ID="ContactMethod" />
              <Property ID="ActualStartDate" />
              <Property ID="ActualEndDate" />
              <Property ID="TemplateId" />
              <Property ID="DisplayName" />
            </Class>
          </Seed>
     

<Component Alias="AssignedTo" Count="1">
        <Seed>
          <Class Type="System.Domain.User">
            <Property ID="UserName" />
            <Property ID="Domain" />
          </Class>
        </Seed>
</Component>

<Component Alias="Activity" Count="1">
        <Seed>
<Class Type="System.WorkItem.Activity.ManualActivity">
<Property ID="Id" />
<Property ID="Status" />
<Property ID="Title" />
</Class>
        </Seed>
</Component>

    </Projection>
</CSVImportFormat>


2. Prepare the CSV using excel
I always colored code the SCSM Projection for easy identifying of what information needed.

Take note the Activity that to be imported (YELLOW section), it must match the structure in the coding as be in the coding stated above:
<Component Alias="Activity" Count="1">
<Seed>
<Class Type="System.WorkItem.Activity.ManualActivity">
<Property ID="Id" />
<Property ID="Status" />
<Property ID="Title" />
</Class>
</Seed>
</Component>

3. Ready to import
Both the XML and CSV file are ready to be imported



4. Here you go, this is how does it looks like