Yes, you can use JavaScript to achieve this. The AI command which you were using context is wrong as well.