How to use javascript string functions in depends_on

How to use javascript string functions in depends_on

like eval:doc.item_group.substr(0,1)
When I use it and try to add a new row in the document my control comes out to desktop.
Also gives an error on the console like:
Uncaught TypeError: Cannot read property ‘substr’ of undefined

I have seen that there is a length used in Sales Invoice.

Can anyone give me an idea

Clearly item_group is undefined.

No it is there and if I use this:

eval:in_list([“720-XXXXXX (firmware)”, “500-XXXXXX (rigid pcb)”,“510-XXXXXX (flexi pcb)”,“700-XXXXXX (pc)”,“710-XXXXXX (mobile)”,“730-XXXXXX (test)”,“740-XXXXXX (cpld/fpga)”],doc.item_group)

It is working fine.