Published on InterSystems Developer Community (https://community.intersystems.com)

Home > Javascript exception

Question
Marco Blom · Mar 25, 2017

Javascript exception

Hi community,

I do not understand why I get a 'javaScript exception'?

 

Purpose is to search for a [Country] based upon a [Code] as search parameter.

this is my code:

<hgroup>
<text id="CountryID" name="Code" label="Code" size ="8" />
<spacer width="5"/>
<text id="CountryName" name="CName" label="Country" size ="24" />
</hgroup>
<spacer height="5"/>
<button caption="Search" onclick="zenPage.searchValue();"/>

</page>
}

ClientMethod searchValue() [ Language = javascript ]
{
var ctrl = zen('CountryID');
tVar = ctrl.getValue();
alert (tVar); ///test-show text value
zenPage.sqlTest(tVar);
}

Method sqlTest(tVar) [ ZenMethod ]
{
SET InVal = tVar
   &sql(SELECT Countrie
        INTO :OutVal
        FROM ZenCrm_Data.Countries
        WHERE CountrieCode=:InVal)
   IF SQLCODE'=0 { SET OutVal="?" 
      IF OutVal="?" {
      WRITE !,"No data returned"
      WRITE !,"SQL error code ",SQLCODE } }
   ELSE {
   WRITE !,"Name is: ",OutVal}
}
 

Does the method needs a 'Return' statement ore something?

Can somebody explain please? this might help me with other programming issue's to!

Thanks in advance,

#Beginner #JavaScript #Caché

Source URL:https://community.intersystems.com/post/javascript-exception