KNOWLEDGE BASE
Log In    |    Knowledge Base    |    4D Home
Tech Tip: Getting the path of a selected list item in a hierarchical list
PRODUCT: 4D | VERSION: 13.3 | PLATFORM: Mac & Win
Published On: June 27, 2013

The following method can be used for getting the path of a selected list item:

//example:
//$path_t:=LIST_GET_PATH(List;Selected list item(List;*))

// Method Name: LIST_GET_PATH
C_TEXT($0;$itemName_t)
C_LONGINT($1;$list_l)
C_LONGINT($2;$listRef_l)

C_LONGINT($newRef_l)

If (Count parameters>=1)
   $list_l:=$1
   $listRef_l:=$2

   If (Is a list($list_l))
      $pos_l:=List item position($list_l;$listRef_l)
      GET LIST ITEM($list_l;$pos_l;$newRef_l;$itemName_t)

      $parentRef_l:=List item parent($list_l;$listRef_l)
      If ($parentRef_l>0)
         $itemName_t:=LIST_GET_PATH ($list_l;$parentRef_l)+"/"+$itemName_t
      End if
   End if
End if

$0:=$itemName_t


This can be used, for example, in the On Clicked form event of a Hierarchical List:
Case of
   : (Form event=On Clicked)
   path_t:=LIST_GET_PATH(List;Selected list items(List;*))
End case


The following screen shot depicts the usage of this method when clicking on an item in the list: