Skip to main content

Hi Team,

I am getting error in my client script.

Below find the detail requirement

Table - ESCALATION

COLUMN - USER_DEF12 , USER_DEF5

User_def12 (dropdown) contains - BRT_BUS,AMT_BUS 

user_def5 (text box)- bus_no

The user wants that if user_def12 is AMT_BUS , then the bus number should belong to AMT. Otherwise, it should throw an error saying "Bus number is not valid." They have provided all the bus no . so I have added those bus no in the global_code_table. 

So for this i have created a client script 

Below find my script

var transittype = getControlValue("escalation", "user_def12");

if (transittype == "AMT_BUS") {  
    var busNumber = getControlValue("escalation", "user_def5");
    var query = stringFormat("SELECT code_value FROM global_code_table WHERE code_name = 'IN_AHM_AMT_BUS_NO' AND Description = '{0}' AND code_value = '{1}'", transittype, busNumber);
    var regno = getDBValue(query);

    if (regno) {
        // If regno is not null or empty, it means the bus number is correct
        alert("Bus number is correct.");
    } else {
        // If regno is null or empty, it means the bus number is wrong
        alert("Bus number is incorrect.");
    }
} else {
    alert("Transit type is not AMT_BUS, validation skipped.");

 

 

Here in the variable “reg_no” ,getting value undefined. 

Please help me out on this

 

Thanks In advance

Hi @aishwarya 

It is a bit hard to follow

First in your query ‘...Description = '{0}' ...’ is redundant. Enough to use code value and name.

Second, to check if a value is empty use method - isNullOrEmptyString. Returns True when the value is null or an empty string.

Third, if you know your transittype is AMT_BUS, why not hardcode it in the query? and use a parameter?

Lastly, run your query in the mobile client and see if any value is returned.

Cheers!


Hi @aishwarya 

It is a bit hard to follow

First in your query ‘...Description = '{0}' ...’ is redundant. Enough to use code value and name.

Second, to check if a value is empty use method - isNullOrEmptyString. Returns True when the value is null or an empty string.

Third, if you know your transittype is AMT_BUS, why not hardcode it in the query? and use a parameter?

Lastly, run your query in the mobile client and see if any value is returned.

Cheers!

 

 

 

Hi @Shneor Cheshin 

query variable contain below query after execution.

SELECT code_value FROM global_code_table WHERE code_name = 'IN_AHM_AMT_BUS_NO' AND Description = 'AMT_BUS' .

The above query is working fine in the sql.

But the below line giving undefined value in regno. 

var regno = getDBValue(query);

so, weare not getting why getDBValue(query)  is returning undefined value.

 

could you please suggest a solution to resolve this problem.

 

Thanks in Advance

 

 

 


Hi @aishwarya 

Try using getDBValues instead of getDBValue.

Something like below

	var regno = getDBValues(stringFormat("SELECT code_value FROM global_code_table WHERE code_name = 'IN_AHM_AMT_BUS_NO' AND Description = 'AMT_BUS' AND code_value = '{0}'", busNumber));
alert(regnog0]["code_value"]);

The above query is working fine in the sql.

Did you try it in mobile? Not server side.

Cheers!


@aishwarya,

 

is the ‘IN_AHM_AMT_BUS_NO’ global code present in the mobile device database? if not you might have to modify the sync rule for the global_code_table.

 

If it is present, try logging the sql query within the script itself to see if there are any syntax errors (try using ‘alert’ or ‘log’ functions.

 

Also inspect the mobile device log to see if there are any runtime errors when executing the script 


@aishwarya,

 

is the ‘IN_AHM_AMT_BUS_NO’ global code present in the mobile device database? if not you might have to modify the sync rule for the global_code_table.

 

If it is present, try logging the sql query within the script itself to see if there are any syntax errors (try using ‘alert’ or ‘log’ functions.

 

Also inspect the mobile device log to see if there are any runtime errors when executing the script 

Hi ​@IniNimesK 

I have checked my query in mobile application .Got all the data according to the query. Even checked Global code . there also i have checked  .it is also fine. 

 

could you please suggest what i need to do further?

 

Thanks in advance


Reply