Skip to main content

Hi Team,

I need to validate the bus number against the registration number. So, I was using the below query. The issue is that when I add an integer value to the bus number field, the registration number gets populated, but I also want the registration number to be shown when I enter a string value in the bus number field then also registration no should populate in mobile application.

below find the reference of query and mobile screen attachment. I want the result to be like the second screenshot. now when my input type is string registration no is not fetching.

var busno = getControlValue("escalation", "user_def5");
var regno = getDBValue(stringFormat("select code_value from global_code_table where code_name = 'IN_AHM_AMT_BUS_NO' and sequence = '{0}'order by sequence", busno ));
setControlValue("ESCALATION","USER_DEF24", regno);

 

Hi @aishwarya,

Can you post a screenshot of the global code you are searching? 

Because generally the ‘sequence’ field in the global_code_table is numeric and it will yield no results if searched by a string value.


Hi @IniNimesK 

thank you for your response.

please find the attachment for your reference


Hi @aishwarya,

Can you post a screenshot of the global code you are searching? 

Because generally the ‘sequence’ field in the global_code_table is numeric and it will yield no results if searched by a string value.

@aishwarya as mentioned here it seems like you need to build a proper mapping to search instead of using the sequence field. Either using a user_def or using the parent code values in the global code table. 


Hi @IniNimesK,

Thank you for your response. Request if you can elaborate on this or help me with an example.


Hi Team,

Now the requirement has been changed

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

 

 

 

 

 


Reply