When you use the NAMEDITEM SCL function with the TYPE argument, the following error message might occur:
ERROR: Invalid list item index.
This issue occurs when there is no matching item with the name that you searched for.
Use the NAMEDITEM function without the TYPE argument, and use the ITEMTYPE function with NAMEDITEM.
Here are some examples:
type=itemtype(listid,nameditem(listid,'NAME',1,1,'Y'));
OR
idx=nameditem(listid,'NAME',1,1,'Y');
if idx>0 then type=itemtype(listid,idx);