none
Importing custom CIs into SCSM

    Question

  • I have created a custom CI and would like to import them AND their user assignments, via the csv and xml files as described here: http://blogs.technet.com/b/servicemanager/archive/2009/05/26/using-the-csv-import-feature.aspx.

    All of our users have been imported into SCSM via an Active Directory connection.  The CSV file I will be using for the import has the user assignment names that I'd like to map to the shared CI property "Owned By User", but I suspect it is not as simple as that... since this is a relationship with 'user'... not to mention i attempted it and got the error "Could not find property named System.ConfigItemOwnedByUser in class DevKit"...

    So, if my current xml file looked something like this:

    <CSVImportFormat>
     <Class Type="CustomCI">
    	<Property ID="System.ConfigItemOwnedByUser"/>
    	<Property ID="DisplayName"/>
    	<Property ID="AssetTag"/>
    	<Property ID="Type"/>
    	<Property ID="AssetStatus"/>
    	<Property ID="Location"/>
    	<Property ID="LastUserAssignmentDate"/>
    	<Property ID="LastUserReturnDate"/>
    	<Property ID="Notes"/>
     </Class>
    </CSVImportFormat>
    
    how do I go about getting the 'config item owned by user' info to populate with the data from the csv?  Is this where I need to utilize a 'projection'?  I don't see anything in appendix A regarding users...
    Wednesday, January 05, 2011 2:43 AM

All replies

  • http://social.technet.microsoft.com/Forums/en-US/administration/thread/7ca0780b-f13a-40dc-bdb2-1c07249fa629/#218c9cde-0771-47c7-8132-f85229f90115

    Look answer for my post

    Wednesday, January 05, 2011 1:43 PM
  • Thanks.  The second link (Importing Software Related to Computers Via CSV) has pointed me in the right direction...  It would be so helpful is there was an example of importing AND assigning custom CIs to users via csv, a task I'd imagine would be fairly common...  After reading through those posts, I think I have to first import the custom CI's unassigned, then run a second import that assigns them to the custom ci.  
    Wednesday, January 05, 2011 8:23 PM
  • You can do both in a single import, actually. As long as your CSVImportFormat xml is layed out correctly, you can import new objects and related objects at the same time whether they already exist or not. It will create/update/relate the objects and related objects as necessary on the fly.

    Your first post has a CSVImport.docx file listed at the bottom..that docx file contains all the details you'll need to setup a CSV import. It also includes examples of how to import objects and their related objects in one shot (starting on page 7). It's a long read but well worth it. The CSV Import feature has saved me tons of hours of work.

    Wednesday, January 05, 2011 9:18 PM
  • Thanks Aaron,

    I have read through those docs... a few times now... I dont' find them so much a long read as a confusing one (for me at any rate).

    After yet another day of no success, I once again put out a call for a concrete example.  An example of a *custom* Configuration Item assigned to an existing scsm user.

    This test implementation of SCSM has been quite a learning curve so far... To date the aspects I thought would be challenging, were not that challenging, and the aspects I thought would be a snap, like importing hardware from an cvs file, turn out to be quite obtuse.

    In the case of a custom CI, I beleive I must use one of these two projections:

    System.ConfigItem.Projection
    or
    System.UserOwnedConfigItems.ProjectionType

    Since my goal is to import one type of asset from our asset assignment spreadsheet into SCSM, I need to get both the asset and its assignment into SCSM.  The custom CI has the configuration item shared properties "System.ConfigItemOwnedByUser" and "System.ConfigItemServicedByUser".  I assume the best option for these fields is to use them as the assignment to the end user, and the serviced by to be assigned to an IT Staff member. Looking through Appenix A, I see "System.ConfigItem.Projection" has a "System.Domain.User" seed, but the "System.UserOwnedConfigItems.ProjectionType" has "OwnedConfigItems" (a relationship I beleive) with "System.Domain.User".  I'm not sure which one of these projections I should be using, I suspect the "System.ConfigItem.Projection" since I want to import all of the assets into my custom CI.  But, at the same time, the "System.UserOwnedConfigItems.ProjectionType" has all of the "OwnedConfigItems" relationships...

    I've attempted many differnet variations on this xml file, all failed.  I get erros that mention line numbers and a problem, and that helped to a certain extent, but now I am merely circling with these errors...

    The last rendition of this file before I gave up for another day was:

    <CSVImportFormat>
     <Projection Type="System.ConfigItem.Projection">
      <seed>
        <Class Type="System.ConfigItem.MyCustomCI">
         <Property ID="DisplayName"/>
         <Property ID="AssetTag"/> (primary key)
         <Property ID="Type"/>
         <Property ID="AssetStatus"/>
      <Property ID="LastUserAssignmentDate"/>
      <Property ID="LastUserReturnDate"/>
      <Property ID="SerialNumber"/>
      ...
      <Property ID="Notes"/>
        </Class>
       </seed>
       <Component Alias="RelatedConfigItems">
        <seed>
         <Class Type="System.ConfigItemOwnedByUser">
          <Property ID="Owned By User"/>
         </Class>
        </seed>
       </Component>
       <Component Alias="RelatedConfigItems">
        <seed>
         <Class Type="System.ConfigItemServicedByUser">
         <Property ID="Serviced By User"/>
         </Class>
        </seed>
       </Component>
     </Projection>
    </CSVImportFormat>

    Thanks

    Saturday, January 08, 2011 2:58 AM
  • Hi

    Also trying to do the same, and can't get the xml file correct , so very interested in any success

     


    /Micke
    Tuesday, January 11, 2011 6:50 AM
  • For custom CI imports, I tend to make my own type projections for them..that way I know exactly what's expected.

    In your case you want to relate a custom CI to users through the Owned by User and Serviced by User relationships. So, I'd make a type projection like this (assuming your CustomCI inherits from System.ConfigItem):

    <TypeProjection ID="My.CustomCI.Projection" Accessibility="Public" Type="System.ConfigItem.CustomCI">
     <Component Path="$Target/Path[Relationship='System!System.ConfigItemOwnedByUser']$" Alias="Owner" />
     <Component Path="$Target/Path[Relationship='System!System.ConfigItemServicedByUser']$" Alias="Servicer" />
    </TypeProjection>
    
    
    

    Next you'll want to define your CSV Format file around that type projection. For example:

    <CSVImportFormat>
     <Projection Type="My.CustomCI.Projection">
     <seed>
      <Class Type="System.ConfigItem.MyCustomCI">
       <Property ID="AssetTag"/> (primary key)
       <Property ID="DisplayName"/>
       <Property ID="Type"/>
       <Property ID="AssetStatus"/>
       <Property ID="LastUserAssignmentDate"/>
       <Property ID="LastUserReturnDate"/>
       <Property ID="SerialNumber"/>
       ...
       <Property ID="Notes"/>
      </Class>
      </seed>
      <Component Alias="Owner" Count="1">
      <seed>
       <Class Type="Microsoft.AD.User">
       <Property ID="UserName"/>
       <Property ID="Domain" />
       </Class>
      </seed>
      </Component>
      <Component Alias="Servicer" Count="1">
      <seed>
       <Class Type="Microsoft.AD.User">
       <Property ID="UserName"/>
       <Property ID="Domain"/>
       </Class>
      </seed>
      </Component>
     </Projection>
    </CSVImportFormat>
    

    Notice that the Alias fields in this format match the aliases in the type projection. Also notice that the class types under each Alias matches the actual class type that you want to import and/or relate. Additionally, since Microsoft.AD.User objects have both a UserName and Domain key property, both must be included.

    Your CSV will then look similar to this:

    1234,CustomCIDisplayName,SomeType,SomeAssetStatus,SomeDate,AnotherDate,SomeSerialNumber,...,"A bunch of notes", UserXUserName,UserXDomain,UserYUserName,UserYDomain

    obviously i have no idea what your data looks like, but this is just an example.

    FYI, I haven't actually tested this type projection, class, or csv format file..but theoretically it should work :)

    Tuesday, January 11, 2011 5:59 PM
  • Thank you so much Aaron.

    This gives me more of an idea of what is necessary. On top of being unfamiliar with the naming conventions, I am lacking in xml foo...

    Another question if I may... are both sections you display above all in the same file?  Or do I need to create the type projection first, and then import the CSV format file?   Currently I am getting errors like this:

    "Exception: System.Xml.XmlException: There are multiple root elements. Line 5, position 2."

    That is with a file like so:

    <TypeProjection ID="MyCustomCI.Projection" Accessibility="Public" Type="System.ConfigItem.MyCustomCI">
    <Component Path="$Target/Path[Relationship='System!System.ConfigItemOwnedByUser']$" Alias="Owner" />
    <Component Path="$Target/Path[Relationship='System!System.ConfigItemServicedByUser']$" Alias="Servicer" />
    </TypeProjection>
    <CSVImportFormat>
    <Projection Type="MyCustomCI.Projection">
    <seed>
    <Class Type="System.ConfigItem.MyCustomCI"/>
    <Property ID="Owner"/>
    <Property ID="Servicer"/>
    <Property ID="DisplayName"/>
    <Property ID="AssetTag"/>
    <Property ID="Type"/>
    <Property ID="AssetStatus"/>
    <Property ID="Location"/>
    <Property ID="Studio"/>
    <Property ID="Project"/>
    <Property ID="LastUserAssignmentDate"/>
    <Property ID="LastUserReturnDate"/>
    <Property ID="SerialNumber"/>
    <Property ID="OEMPartNumber"/>
    ...
    <Property ID="Notes"/>
    </Class>
    </seed>
    <Component Alias="Owner" Count="1">
    <seed>
    <Class Type="Microsoft.AD.User">
    <Property ID="UserName"/>
    <Property ID="Domain" />
    </Class>
    </seed>
    </Component>
    <Component Alias="Servicer" Count="1">
    <seed>
    <Class Type="Microsoft.AD.User">
    <Property ID="UserName"/>
    <Property ID="Domain"/>
    </Class>
    </seed>
    </Component>
    </Projection>
    </CSVImportFormat>
    
    

     Thanks again

    • Edited by kpm8 Wednesday, January 12, 2011 1:11 AM correction
    Wednesday, January 12, 2011 12:57 AM
  • yep, the type projection has to be defined in a management pack. You could put it in your CustomCI MP.

    Wednesday, January 12, 2011 2:35 PM
  • Hi Aaron, I've been distracted with another problem of not being able to import a custom CI mp back into the authoring tool, but now that it is solved,  I am back on this one...

    I am now ensuring I can export and import my custom CI mp into the authoring tool before I make any changes to it.  As it stands freshly exported from scsm, I can import it into the authoring too.  However, after editing it and adding the above explained "TypeProjection", I am unable to open the file again in the authoring tool.  I edit the file in notepad, save and close it, then attempt to import it to the Authoring Tool, and nothing happens.  No error, nothing...  the file just doesn't open.

    I must be placing the TypeProjection in the wrong place, or I am missing info... I have attempted to place it between the manifest and type definitions, and at the bottom of the file just after the language packs.  Same results, no error, file doesn't open.

    Thanks

    Thursday, January 13, 2011 8:52 PM
  • Morning kpm8,

    1) In the Authoring Tool, when you try to open your MP and get nothing happening, look for the "Output" tab (At the bottom of my screen) and click that as it's minimised by default.  This should give you a bit more information on why it failed to open your MP.

    2) Type Projections live Under TypeDefinitions, then Entitytypes at the same level as ClassTypes and RelationshipTypes.

    <TypeDefinitions>
     <EntityTypes>
      <TypeProjections>
       <TypeProjection ID="Custom.TypeProjection" Accessibility="Public" Type="CustomCI">
        <Component Path="$Context/Path[Relationship='System!System.ConfigItemOwnedByUser']$" Alias="CustomCIOwnedByUser"/>
       </TypeProjection>
      </TypeProjections>
     </EntityTypes>
    </TypeDefinitions>
    

    My System Center Blog
    Friday, January 14, 2011 11:43 AM
  • To add to Steve's post, things under EntityTypes have to be in a certain order:

    ClassTypes
    RelationshipTypes
    EnumerationTypes
    TypeProjections

    You don't have to have all of those in your managementpack, of course, but whichever ones you have must appear in the correct order

    eg: if you only have your customCI class and a type projection, your EntityTypes section would look something like:

    <TypeDefinitions>
     <EntityTypes>
      <ClassTypes>
       <ClassType ID="System.ConfigItem.MyCustomCI" Accessibility="Public" Abstract="false" Base="System!System.ConfigItem" Hosted="false" Singleton="false" Extension="false">
        <Property... />
       </ClassType>
      </ClassTypes>
      <TypeProjections>
       <TypeProjection ID="MyCustomCI.Projection" Accessibility="Public" Type="System.ConfigItem.MyCustomCI">
        <Component Path="$Target/Path[Relationship='System!System.ConfigItemOwnedByUser']$" Alias="Owner" />
        <Component Path="$Target/Path[Relationship='System!System.ConfigItemServicedByUser']$" Alias="Servicer" />
       </TypeProjection>
      </TypeProjections>
     </EntityTypes>
    </TypeDefinitions>
    
    
    Friday, January 14, 2011 3:09 PM
  • :O  You learn something new every day!

    Thanks for that Aaron, I've just been incredibly lucky getting them in that order so far by chance but at least I know to do it specifically like that in future :)

    Cheers,
    SB


    My System Center Blog
    Friday, January 14, 2011 3:13 PM
  • Thanks again for all the help.  I've discovered another twist...

    I've been using the default form that SCSM generates when one creates a custom CI. But last night I created a custom form, and on that custom form I added the "Owned By User" field, dragged out a 'user picker' and bound it to "Owned By User".  Now, when I look at the custom ci xml file, I can see a TypeProjection added:

    <TypeProjections>
     <TypeProjection ID="MyCustomCIForm_TypeProjection" Accessibility="Public" Type="MyCustomCI">
     <Component Path="$Context/Path[Relationship='System!System.ConfigItemOwnedByUser']$" Alias="ComponentAlias_5cc58740_52c6_4d2f_a564_93a88b482d6a" />
     </TypeProjection>
    </TypeProjections>
    

    However, when I attempt to do the same with "Serviced By User", the only binding options that are made available for me to select are "Owned By User", no "Serviced By User" to be seen...??

    Friday, January 14, 2011 5:48 PM
  • The serviced by user relationship is many-to-many. Unfortuantely, you can't bind a single instance picker or user picker to a relationship component whose MaxCardinality is greater than 1.

    In other words, the target of the relationship is User. The maxcardinality is 2147483647. You would need a multi-instance picker on the form to view those serviced-by users. I don't know if there's any multi-instance picker support for form extensions, though. There's no such control in my version of the authoring tool, and I don't know if there's a way to do it directly in a management pack.

    Friday, January 14, 2011 6:14 PM
  • Ok, so if this is my import xml file:

    <CSVImportFormat>
    	<Projection Type="MyCustomCI_TypeProjection">
    		<seed>
    			<Class Type="System.ConfigItem.MyCustomCI">
    				<Property ID="Current Assignment"/>
    				<Property ID="DisplayName"/>
    				<Property ID="AssetTag"/>
    				<Property ID="Type"/>
    				<Property ID="AssetStatus"/>
    				<Property ID="Location"/>
    				etc...
    				<Property ID="Notes"/>
    			</Class>
    		</seed>
    		<Component Alias="ComponentAlias_6cb3a461_4ff4_4877_88d1_42034bdba31d" Count="1">
    			<seed>
    				<Class Type="Microsoft.AD.User">
    					<Property ID="Current Assignment"/>
    					<Property ID="Domain" />
    				</Class>
    			</seed>
    		</Component>
    	</Projection>
    </CSVImportFormat>
    

    ...and my TypeProjection section from the Authoring Tool made MyCustomCI mp is:

    <TypeProjections>
     <TypeProjection ID="MyCustomCIForm_TypeProjection" accessibility="Public" Type="MyCustomCI">
     <Component Path="$Context/Path[Relationship='System!System.ConfigItemOwnedByUser']$" Alias="ComponentAlias_6cb3a461_4ff4_4877_88d1_42034bdba31d" />
     </TypeProjection>
    </TypeProjections>
    
    

     When I attempt to import, I get the following error:

    "The element 'Projection' has invalid child element 'seed'. List of possible elements expected: 'Seed'.

    "Child nodes of element Projection must be named "Seed" or "Component""

    "Line number: 2, Position: 3"

    "Could not initialize a Management Object Creator from format file C:\import.xml. Import thread exiting."

     

     

    Friday, January 14, 2011 10:44 PM
  • How can we apply kind of Foreign key constraint as in SQL for the CSV import.

    Conside a situation I have two classes which I use for CSV import.
    While performing CSV import for column "Eligible Countries" of Class A it should import only those values
    present in "Eligible Countries" of Class B.
    The columns are of List-enum type stored as Guid's in database.

    Wednesday, June 20, 2012 3:39 PM