KNOWLEDGE BASE
Log In    |    Knowledge Base    |    4D Home
Tech Tip: Getting the Reference ID of the selected list item
PRODUCT: 4D | VERSION: | PLATFORM: Mac & Win
Published On: May 16, 2002
Your current browser may not allow you to download the asset. We recommend Mozilla Firefox or Google Chrome.
Log In

Compatibility: 6.5.x , 6.7.x, and 6.8.x
Platforms: Windows and Mac OS

Here is a method that retrieves the reference ID of the selected list item:


` Project Method: GetSelectedListItemRef

` Description: Return the Reference ID of the selected list item

`

` $1 - Pointer to a list

C_TEXT($itemText)

C_BOOLEAN($expand)

C_POINTER($1;$ptr)

C_LONGINT($0;SelectedPosition;$RefItem;$style;$SubRef)

$1;$ptr

$SelectedPosition:=Selected list item($ptr->)


GET LIST ITEM($ptr->;$SelectedPosition;$RefItem;$itemText;$SubRef;$expand)


$0:=$RefItem


To use this project method, you can call it from the Object method of a Hierarchical List. Here is how you can call it:

If (Form event=On Clicked)

GetSelectedListItemRef(Self)


End if


For Example:


The item reference numbers are set as follows


Item Ref ID


A 100

AAA 101

BBB 102

CCC 103

X 200

XXX 201

YYY 202

ZZZ 203

999 300

111 301

222 302

333 303


When the item is selected in the Hierarchical List, the project method GetSelectedListItemRef retrieves the reference ID of the selected item and returns it as the function result.


For example:

If BBB is selected, GetSelectedListItemRef will return 102

If XXX is selected, GetSelectedListItemRef will return 201

If 333 is selected, GetSelectedListItemRef will return 303