Written by

Question Nezla · Sep 22, 2023

Javascript in Methods or class methods

Hi Guys,

I've this client method in my Zen page which looks good and compile fine:

I first tried calling  this clientmethod in %DrawHTML() like : var res=zenPage.getNewPrinters(); but for some reason didn't work not sure why I even tried simplifying my clientMethod with simple code like just showing alert but still this call didn't work

So now I'm  trying copying the code of my clientmethod to %DrawHTML()  but I'm getting a compilation error not sure why everything is the same so why is this code is raising a compalation error when placed between &js<> and working fine in my clientMethod?

I actually tried copying this code to other classMethods placing it insode &js<> and still get the same compilation problem, I'm starting to this that this type of javascript syntax in not compliant in &js<> !?

 

so what I'm doing wrong? 

Thanks

Product version: Ensemble 2018.1

Comments

Dmitry Maslennikov · Sep 22, 2023

The issue is just in `<` sign in the javascript code, replace it with something else, without <>.

0
Dmitry Maslennikov  Sep 22, 2023 to Dmitry Maslennikov

Or use extra symbol for &js, like @, see example

ClassMethod OnPage() As %Status
{
    &js@<
    if ( a > 1) {
        console.log('test')
    }
    >@
	Quit $$$OK
}
0
Nezla  Sep 22, 2023 to Dmitry Maslennikov

Thanks Dmitry.

0