item element
The item element is used to retrieve an item from the Dynamics CRM repository, and insert the value of this item into the document metadata.
| Attribute | Description | Required |
|---|---|---|
name
|
The name of the item to retrieve. | Yes |
position_in_document
|
The location in the document where you want to insert value of the item:
|
No |
field_name
|
The name of the document field to create to contain the item value. By default, the document field takes the name of the item. | No |
Example
The following example creates a document for each account in the repository. These documents have fields named accountid, name, and description which contain information about the account. The document also has a field named owninguser, and this field has sub-fields named employeeid and fullname.
<?xml version="1.0" encoding="utf-8"?>
<spec>
<collection name="accounts">
<item name="accountid" />
<item name="name" />
<item name="description" />
<object name="owninguser">
<item name="employeeid" />
<item name="fullname" />
</object>
</collection>
</spec>
An example of a document produced by this specification appears below:
<DOCUMENT>
<DREREFERENCE>http://host/Dynamics/api/data/v8.1/accounts(34b8ffd0-4232-e611-80c5-0050569248a7)</DREREFERENCE>
<accountid>34b8ffd0-4232-e611-80c5-0050569248a7</accountid>
<description>This is the description</description>
<name>Hewlett Packard Enterprise</name>
<owninguser>
<employeeid>0123456</employeeid>
<fullname>John Smith</fullname>
</owninguser>
</DOCUMENT>
If you wanted to use the field name accountname for the account name, instead of name, you could use the field_name attribute as follows:
<?xml version="1.0" encoding="utf-8"?>
<spec>
<collection name="accounts">
<item name="accountid" />
<item name="name" field_name="accountname" />
<item name="description" />
<object name="owninguser">
<item name="employeeid" />
<item name="fullname" />
</object>
</collection>
</spec>
An example of a document produced by this specification appears below:
<DOCUMENT>
<DREREFERENCE>http://host/Dynamics/api/data/v8.1/accounts(34b8ffd0-4232-e611-80c5-0050569248a7)</DREREFERENCE>
<accountid>34b8ffd0-4232-e611-80c5-0050569248a7</accountid>
<accountname>Hewlett Packard Enterprise</accountname>
<description>This is the description</description>
<owninguser>
<employeeid>0123456</employeeid>
<fullname>John Smith</fullname>
</owninguser>
</DOCUMENT>
To insert the metadata about the owninguser object at the root level of the document, and not as sub-fields, you could use the position_in_document attribute, for example:
<?xml version="1.0" encoding="utf-8"?>
<spec>
<collection name="accounts">
<item name="accountid" />
<item name="name" field_name="accountname" />
<item name="description" />
<object name="owninguser">
<item name="employeeid" position_in_document="root" />
<item name="fullname" position_in_document="root" />
</object>
</collection>
</spec>
An example of a document produced by this specification appears below:
<DOCUMENT> <DREREFERENCE>http://host/Dynamics/api/data/v8.1/accounts(34b8ffd0-4232-e611-80c5-0050569248a7)</DREREFERENCE> <accountid>34b8ffd0-4232-e611-80c5-0050569248a7</accountid> <accountname>Hewlett Packard Enterprise</accountname> <description>This is the description</description> <employeeid>0123456</employeeid> <fullname>John Smith</fullname> </DOCUMENT>