ItemByKeys method: Data collection

Syntax

ItemByKeys(­key_values)

Description

The ItemByKeys method returns the item specified by the parameters. The number and type of keys are unique to each specific collection. Each key must be separated by a comma.

The collection reference must be the name of the Component Interface, followed by the record name. This method won’t work on a collection reference (that is, &CI.RECNAME.ItemByKeys, not &MYCOLLECTION.ItemByKeys).

After you’ve returned an item, use the ItemNum property to determine the number of the item.

The keys must be in the exact order as in the Component Interface. A second level data collection also contains the keys of the parent data collection.

An easy way to determine the keys and their order in PeopleCode is to open the Component Interface in Application Designer, and use the Test Component. To determine the keys in Visual Basic, use the Object Browser.

See ItemNum property: Data Item class.

To see the signature for ItemByKeys:

  1. Open the Component Interface in Application Designer.

  2. Start the Component Interface Tester.

    Select the open Component Interface, then right-click, and select Test Component Interface from the pop-up menu.

  3. Instantiate an object.

    Add data to the Get or Create keys and click Get Existing or Create New, respectively.

  4. Expand the instantiated component until you find the collection in which you’re interested.

  5. Right-click on the collection and select ItemByKeys from the resulting pop-up menu.

  6. The dialog that follows shows you the specific parameters, types, and order in which you should call ItemByKeys.

Returns

An item (row) of data from a data collection.

Example

Local ApiObject &MYSESSION;
Local ApiObject &CI;
Local ApiObject &CI_COLLECTION;
Local ApiObject &CI_ITEM;

&MYSESSION = %Session;
&CI = &MYSESSION.GetCompIntfc(COMPINTFC.CM_EVAL);
&CI.EMPLID = "8001";
If &CI.Get() <> 1 Then
   Exit;
End-If;

&CI_COLLECTION = &CI.CM_EVALUATIONS;
&COUNT = &CI_COLLECTION.Count;

&CI_ITEM = &CI.CM_EVALUATIONS.itembykeys("01");
&CI_ITEM.DESCR50 = "TEST";
If &CI.Save() <> 1 Then
   Exit;
End-If;