| Siebel CRM Desktop for Microsoft Outlook Administration Guide > Customizing Siebel CRM Desktop  > Process of Adding an MVG Field > Example Code You Use to Add an MVG
 This topic describes some of the code you use to add an MVG in this example. It includes the following topics: Code to Add a Custom Object TypeTo add a custom object type, you add the following code anywhere in the siebel_meta_info.xml file. To assist with debugging, it is recommended that you place this code after the last Type definition: <object TypeId='ChannelPartner' Label='Channel Partner' LabelPlural='Channel Partners' EnableGetIDsBatching='true' ViewMode='Sales Rep' IntObjName='Channel Partner' SiebMsgXmlElemName='ChannelPartner' SiebMsgXmlCollectionElemName='ListOfChannelPartner' >   <field Name='DS Updated' Label='DS Updated' DataType='DTYPE_DATETIME' IsFilterable='no' IsHidden='yes' IOElemName='DSUpdated' />   <field Name='Id' Label='Id' IsPrimaryKey='yes' DataType='DTYPE_ID' IsFilterable='no' IsHidden='yes' IOElemName='Id'/>   <field Name='Name' Label='Name' DataType='DTYPE_TEXT' IsPartOfUserKey='yes' IOElemName='Name' />   <field Name='Location' Label='Location' DataType='DTYPE_TEXT' IsPartOfUserKey='yes' IOElemName='Location'/> </object> This code does the following: 
Uses properties of the integration object and integration component as the values for attributes.
References only a few of the many fields that exist in the Channel Partner object in Siebel CRM. 
Uses the Name and Location fields as parts of the user key. You define the natural key in the connector_configuration.xml file.
 Code to Map a Custom ObjectYou can map a field of a Siebel CRM object to a Microsoft Outlook field or to a custom Siebel CRM Desktop field. For example, you can do the following: 
Map the Name field in Siebel CRM to the LastName field in Microsoft Outlook
Map the mapLocation field in Microsoft Outlook to the Location field in Siebel CRM
 To map objects, you add the following code to the siebel_basic_mapping.xml file: <type id="ChannelPartner" hidden_folder="true" folder_type="10" display_name="CHPT">  <form message_class="IPM.Contact.SBL.Channel_Partner" display_name="Channel Partner" icon="type_image:User:16"></form>   <field id="Name">    <reader>     <mapi_std>       <mapi_tag id="0x3A110000"></mapi_tag>      <convertor><string/></convertor>     </mapi_std>     </reader>    <writer>     <outlook_std>       <outlook_field id="LastName"></outlook_field>      <convertor><string/></convertor>     </outlook_std>     </writer>    <reader>     <mapi_std>       <mapi_tag id="0x3A060000"></mapi_tag>      <convertor><string/></convertor>     </mapi_std>     </reader>    <writer>     <outlook_std>       <outlook_field id="FirstName"></outlook_field>      <convertor><string/></convertor>     </outlook_std>     </writer>   </field>   <field id="Location">    <reader>     <mapi_user>       <user_field id="sbl Location" ol_field_type="1"></user_field>      <convertor><string/></convertor>     </mapi_user>     </reader>    <writer>     <outlook_user>       <user_field id="sbl Location" ol_field_type="1"></user_field>      <convertor><string/></convertor>     </outlook_user>     </writer>   </field> </type> Note the following requirements: 
The value for the type id tag in the siebel_basic_mapping.xml file must equal the value in the TypeId object in the siebel_meta_info.xml file.
If you define a new type, then you must include the form tag. The forms_xx.xml file includes the form definition. The value for the form tag must equal the form id attribute in the form definition. Because this example does not require a form, the form tag is empty. Even if your example does not require a form, to uniquely identify a type, you must define a value for the mesage_class attribute. This value must start with the following code:
IPM.Contact.SBL Code to Configure Synchronization for a Custom ObjectTo configure synchronization for a custom object, you add the following code to the connector_configuration.xml file: <type id="ChannelPartner">   <view label="Channel Partner" label_plural="Channel Partners" small_icon="type_image:Account:16" normal_icon="type_image:Account:24" large_icon="type_image:Account:48"></view>   <synchronizer name_format=":[:(Name):]">     <links>     </links>     <natural_keys>       <natural_key>         <field>Name</field>         <field>Location</field>       </natural_key>     </natural_keys>   </synchronizer> </type> Note the following: 
The value in the type id tag must equal the value in the TypeId object in the meta_info.xml file.
The natural_key tag includes the Name and Location fields as part of the user key.
 Code to Add a Lookup ViewTo add a lookup view, you add the following code to the lookup_view_defs.xml file: <lookup_view_def key="lookup:channel_partners">     <display name="Channel Partners"></display>     <filter dasl="[http://schemas.microsoft.com/mapi/proptag/0x001A001E] >= 'IPM.Contact.SBL.Channel_Partner' AND [http://schemas.microsoft.com/mapi/proptag/0x001A001E] <= 'IPM.Contact.SBL.Channel_Partner'"></filter>     <view id="channel_partner:salesbook"></view>     <quick_lookup dasl_format="[http://schemas.microsoft.com/mapi/id/{00062004-0000-0000-C000-000000000046}/8005001E] = '%s'"></quick_lookup>     <type id=""></type> </lookup_view_def> Table 20 describes important attributes you use in this code. 
Table 20.	Attributes in the Code to Add a Lookup View
    |  |  |  
    | key | Id of the lookup control. |  
    | display name | Caption of the lookup control.  |  
    |  filter | Object that Siebel CRM Desktop displays on the lookup control. To specify an object type, you use the message_type attribute in the siebel_basic_mapping.xml file. |  
    | view | Id of the salesbook control that Siebel CRM Desktop uses for this lookup.  |  
    | type id | The type of object that Siebel CRM Desktop creates if the user clicks New on the lookup control. If this attribute is empty, then Siebel CRM Desktop disables the button. |  
 Code to Add a ViewTo add the definition for a view, you add the following code to the views.xml file: <str key="channel_partner:mvg">     <![CDATA[<?xml version="1.0"?>     <view type="table">     <viewname>Phone List</viewname>     <viewstyle>table-layout:fixed;width:100%;font-family:Segoe UI;font-style:normal;font-weight:normal;font-size:8pt;color:Black;font-charset:0</viewstyle>     <viewtime>0</viewtime>     <linecolor>8421504</linecolor>     <linestyle>3</linestyle>     <gridlines>1</gridlines>     <collapsestate/>     <rowstyle>background-color:window;color:windowtext</rowstyle>     <headerstyle>background-color:#D3D3D3</headerstyle>     <previewstyle/>     <arrangement>         <autogroup>0</autogroup>         <collapseclient/>     </arrangement>     <multiline>         <width>0</width>     </multiline>     <column>         <name>HREF</name>         <prop>DAV:href</prop>         <checkbox>1</checkbox>     </column>     <column>         <type>string</type>         <heading>Name</heading>         <prop>http://schemas.microsoft.com/mapi/string/{00020329-0000-0000-C000-000000000046}/sbl%20PartnerName</prop>         <width>426</width>         <style>padding-left:3px;;text-align:left</style>         <editable>1</editable>         <userheading>Name</userheading>     </column>     <column>         <type>string</type>         <heading>Location</heading>         <prop>http://schemas.microsoft.com/mapi/string/{00020329-0000-0000-C000-000000000046}/sbl%20PartnerLocation</prop>         <width>426</width>         <style>padding-left:3px;;text-align:left</style>         <editable>1</editable>         <userheading>Location</userheading>     </column>     <orderby>         <order>             <heading>File As</heading>             <prop>urn:schemas:contacts:fileas</prop>             <type>string</type>             <sort>asc</sort>         </order>     </orderby>     <groupbydefault>0</groupbydefault>     <previewpane>         <markasread>0</markasread>     </previewpane>     </view>]]> </str>  Code to Add a New AssociationTo add a new association, you add the following code to the business_logic.js file: var opportunity_channel_partner =         add_mvg_link("Opportunity", "ChannelPartner", "Primary Partner Id", null,                 "Opportunity.Channel_Partner.Association", "OpportunityId", "ChannelPartnerId",                 null, "ChannelPartnerStatus",                  null, ["lookup:channel_partners"],                 false, false, false, true);     deny_primary_delete(opportunity_channel_partner.mvg1);//optional     opportunity_channel_partner.mvg1.dialog_template_params = {         "dialog_caption": "#obj_activity_employee_plural",         "autocomplete_display_format": ":[:(Name):]",         "associations_view_caption": "#head_associated_channel",         "associations_view_id": "channel_partner:mvg",         "primary_selector_display_format": ":[:(PartnerName):]"     } The ChannelPartnerStatus field contains the status of the Channel Partner object, such as unsaved, deleted, and so forth. Table 21 describes the important parameters you can use with the add_mvg_link function. 
Table 21.	Attributes in the Code to Add a New Association
    |  |  |  
    | left_type  | The type of the first linked object. For example, Opportunity. |  
    | right_type  | The type of the second linked object. For example, Channel Partner. |  
    | left_obj_primary  | The field of the Opportunity object. This field contains the primary Id for the Channel Partner object. |  
    | right_obj_primary  | The field of the Channel Partner object. This field contains the primary Id for the Opportunity object. |  
    | assoc_type  | The Id of the association type described in the siebel_meta_info.xml file and the siebel_basic_mapping.xml file. |  
    | left_link  | The field of the association object that contains the Id of the opportunity. |  
    | right_link  | The field of the association object that contains the Id of the channel partner. |  
    | left_assoc_status  | The field of the association that contains the status of the opportunity. |  
    | right_assoc_status  | The field of the association that contains the status of the channel partner. |  
    | left_objs_view_ids  | The list of lookup view definitions you must use to display opportunity objects. |  
    | right_objs_view_ids  | The list of lookup view definitions you must use to display channel partner objects. |  
    | left_primary_refresh_required | If the primary object is changed, and if the left_primary_refresh_required attribute is true, then Siebel CRM Desktop updates the object Id for the primary field of the opportunity that you specify in the left_obj_primary attribute. If you use the following tag in the siebel_basic_mapping.xml file for this field, then set the left_primary_refresh_required attribute to true: writer class="link_fields"
 |  
    | right_primary_refresh_required  | If the primary object is changed, and if the right_primary_refresh_required attribute is true, then Siebel CRM Desktop updates the object Id for the primary field of the channel partner that you specify in the right_obj_primary attribute. If you use the following tag in the siebel_basic_mapping.xml file for this field, then set the right_primary_refresh_required attribute to true: writer class="link_fields"
 |  
    | assoc_left_link_refresh_required  | If the opportunity object is changed, then Siebel CRM Desktop updates the OpportunityId field of the association that you specify in the left_link attribute. If you use the following tag in the siebel_basic_mapping.xml file for this field, then set the assoc_left_link_refresh_required attribute to true: writer class="link_fields"
 |  
    | assoc_right_link_refresh_required  | If the channel partner object is changed, then Siebel CRM Desktop updates the ChannelPartnerId field of the association that you specify in the right_link attribute. If you use the following tag in the siebel_basic_mapping.xml file for this field, then set the assoc_right_link_refresh_required attribute to true: writer class="link_fields"
 |  
 Code to Define a Salesbook ControlTo define a salesbook control, you add the following code to the views.xml file: <str key="channel_partner:salesbook">     <![CDATA[<?xml version="1.0"?>         <view type="table">             <viewname>Phone List</viewname>             <viewstyle>table-layout:fixed;width:100%;font-family:Segoe UI;font-style:normal;font-weight:normal;font-size:8pt;color:Black;font-charset:0</viewstyle>             <viewtime>0</viewtime>             <linecolor>8421504</linecolor>             <linestyle>3</linestyle>             <gridlines>1</gridlines>             <newitemrow>1</newitemrow>             <collapsestate/>             <rowstyle>background-color:window;color:windowtext</rowstyle>             <headerstyle>background-color:#D3D3D3</headerstyle>             <previewstyle/>             <arrangement>                 <autogroup>0</autogroup>                 <collapseclient/>             </arrangement>             <multiline>                 <width>0</width>             </multiline>             <column>                 <name>HREF</name>                 <prop>DAV:href</prop>                 <checkbox>1</checkbox>             </column>             <column>                 <heading>Last Name</heading>                 <prop>urn:schemas:contacts:sn</prop>                 <type>string</type>                 <width>322</width>                 <style>padding-left:3px;;text-align:left</style>                 <editable>1</editable>             </column>             <column>                 <type>string</type>                 <heading>Location</heading>                 <prop>http://schemas.microsoft.com/mapi/string/{00020329-0000-0000-C000-000000000046}/sbl%20Location</prop>                 <width>322</width>                 <style>padding-left:3px;;text-align:left</style>                 <editable>1</editable>                 <userheading>Location</userheading>             </column>             <orderby>                 <order>                     <heading>File As</heading>                     <prop>urn:schemas:contacts:fileas</prop>                     <type>string</type>                     <sort>asc</sort>                 </order>             </orderby>             <groupbydefault>0</groupbydefault>             <previewpane>                 <markasread>0</markasread>             </previewpane>         </view>]]> </str> |