iTop Add a new field (Owner) to Configuration Item

Here we are creating a custom module to add an additional field which is of object type contact  to the FunctionalCI Class which is the parent class of all functional CIs in iTop.
You can either use https://www.itophub.io/wiki/page?id=2_2_0%3Acustomization%3Astart to create an empty module and update the contents of the modules files generated or create those files manually. The custom module should be placed in the extensions folder of the iTop installation. The web server should have read permission on these files.

root@sum-lamp .../extensions/ci-custom-ownerfield# ls
datamodel.sum-ci-addfields.xml en.dict.sum-ci-addfields.php model.sum-ci-addfields.php module.sum-ci-addfields.php

Adding the custom field to the base class (FunctionalCI) (datamodel.sum-ci-addfields.xml)

<class id="FunctionalCI">
<fields>
<field xsi:type="AttributeExternalKey" id="owner" _delta="define">
<sql>owner</sql>
<target_class>Person</target_class>
<is_null_allowed>true</is_null_allowed>
<on_target_delete>DEL_MANUAL</on_target_delete>
</field>
</fields>
</class>

Updating the <presentation> </presentation> block to disaplay the custom field for the corresponding CI (datamodel.sum-ci-addfields.xml)

<class id="NetworkDevice" delta="must_exist">
<presentation>
<details>
<items>
<item id="col:col1">
<items>
<item id="fieldset:Ownership">
<items>
<item id="owner" _delta="define">
<rank>95</rank>
</item>
</items>
</item>
</items>
</item>
</items>
</details>
<search>
<items>
<item id="owner" _delta="define">
<rank>95</rank>
</item>
</items>
</search>
<list>
<items>
<item id="owner" _delta="define">
<rank>95</rank>
</item>
</items>
</list>
</presentation>
</class>

Updating dictionary file (en.dict.sum-ci-addfields.php)

<?php
/**
*
* @copyright Copyright (C) 2018-2019
* @license http://opensource.org/licenses/AGPL-3.0
*/

Dict::Add('EN US', 'English', 'English', array(
// Dictionary entries go here
'Class:FunctionalCI/Attribute:owner' => 'Asset Owner',
));
?>

Content of module.sum-ci-addfields.php

<?php
//
// iTop module definition file
//
SetupWebPage::AddModule(
__FILE__, // Path to the current file, all other file names are relative to the directory containing this file
'sum-ci-addfields/1.1.3',
array(
// Identification
//
'label' => 'CI-Custom-OwnerField',
'category' => 'business',

// Setup
//
'dependencies' => array(
'itop-config-mgmt/2.5.0'
),
'mandatory' => false,
'visible' => true,
// Components
//
'datamodel' => array(
'model.schirrms-server-addfields.php'
),
'webservice' => array(
),
'data.struct' => array(
// add your 'structure' definition XML files here,
),
'data.sample' => array(
// add your sample data XML files here,
),
// Documentation
//
'doc.manual_setup' => '', // hyperlink to manual setup documentation, if any
'doc.more_information' => '', // hyperlink to more information, if any
// Default settings
//
'settings' => array(
// Module specific settings go here, if any
),
)
);
?>

Change permission for config-itop.php for the update

root@sum-lamp .../extensions/ci-custom-ownerfield# chmod u+w /var/www/itop/conf/production/config-itop.php

Invoke http://itoplink/setup for updating the new field

Select the custom module for installation

Custom Owner field in the Network Device Class

 

My full datamodel.sum-ci-addfields.xml file

<?xml version="1.0" encoding="UTF-8"?>
<itop_design xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="1.5">
	<constants>
	</constants>
	<classes>
		<class id="FunctionalCI">
		<fields>
			<field xsi:type="AttributeExternalKey" id="owner" _delta="define">
			<sql>owner</sql>
			<target_class>Person</target_class>
			<is_null_allowed>true</is_null_allowed>
			<on_target_delete>DEL_MANUAL</on_target_delete>
		</field>

	</fields>
	</class>

	<class id="Server" delta="must_exist">
			<presentation>
				<details>
					<items>
						<item id="col:col1">
							<items>
								<item id="fieldset:Ownership">
									<items>
										<item id="owner" _delta="define">
											<rank>95</rank>
										</item>
									</items>
								</item>
							</items>
						</item>

					</items>
				</details>
				<search>
					<items>
						<item id="owner" _delta="define">
							<rank>95</rank>
						</item>
					</items>
				</search>
				<list>
					<items>
						<item id="owner" _delta="define">
							<rank>95</rank>
						</item>
					</items>
				</list>
			</presentation>
		</class>
			<class id="NetworkDevice" delta="must_exist">
			<presentation>
				<details>
					<items>
						<item id="col:col1">
							<items>
								<item id="fieldset:Ownership">
									<items>
										<item id="owner" _delta="define">
											<rank>95</rank>
										</item>
									</items>
								</item>
							</items>
						</item>

					</items>
				</details>
				<search>
					<items>
						<item id="owner" _delta="define">
							<rank>95</rank>
						</item>
					</items>
				</search>
				<list>
					<items>
						<item id="owner" _delta="define">
							<rank>95</rank>
						</item>
					</items>
				</list>
			</presentation>
		</class>
			<class id="VirtualMachine" delta="must_exist">
			<presentation>
				<details>
					<items>
						<item id="col:col1">
							<items>
								<item id="fieldset:Ownership">
									<items>
										<item id="owner" _delta="define">
											<rank>95</rank>
										</item>
									</items>
								</item>
							</items>
						</item>

					</items>
				</details>
				<search>
					<items>
						<item id="owner" _delta="define">
							<rank>95</rank>
						</item>
					</items>
				</search>
				<list>
					<items>
						<item id="owner" _delta="define">
							<rank>95</rank>
						</item>
					</items>
				</list>
			</presentation>
		</class>
		
					<class id="GenericCommDevice" delta="must_exist">
			<presentation>
				<details>
					<items>
						<item id="col:col1">
							<items>
								<item id="fieldset:Ownership">
									<items>
										<item id="owner" _delta="define">
											<rank>95</rank>
										</item>
									</items>
								</item>
							</items>
						</item>

					</items>
				</details>
				<search>
					<items>
						<item id="owner" _delta="define">
							<rank>95</rank>
						</item>
					</items>
				</search>
				<list>
					<items>
						<item id="owner" _delta="define">
							<rank>95</rank>
						</item>
					</items>
				</list>
			</presentation>
		</class>
		
							<class id="WebApplication" delta="must_exist">
			<presentation>
				<details>
					<items>
						<item id="col:col1">
							<items>
								<item id="fieldset:Ownership">
									<items>
										<item id="owner" _delta="define">
											<rank>95</rank>
										</item>
									</items>
								</item>
							</items>
						</item>

					</items>
				</details>
				<search>
					<items>
						<item id="owner" _delta="define">
							<rank>95</rank>
						</item>
					</items>
				</search>
				<list>
					<items>
						<item id="owner" _delta="define">
							<rank>95</rank>
						</item>
					</items>
				</list>
			</presentation>
		</class>
	</classes>
	<user_rights>
		<groups>
		</groups>
		<profiles>
		</profiles>
	</user_rights>
</itop_design>

 

Please follow and like us: