Skip to main content

Hi All,

 

I want to hide particular drop down  value(Scrap) once the from part need checkbox is unchecked in mobile.

 

Once I click on the from part need checkbox I should be able to hide the Scarp value only from the dropdown not the (Installed and Transfer To Vanstock values)

 

Below is my code but its not working as expected kindly help.

 

var IsChecked = getControlValue("custom","from_part_needs");
if (IsChecked == 'N') 
{
   var conSump = stringFormat("SELECT description, code_value FROM global_code_table WHERE code_name = 'ELUX_CONSUMPTION_TYPES' AND code_value != 'Scrap'");
   populateListFromQuery('part_usage','user_def16', conSump, false);
}
else
{
    var conSump = stringFormat("SELECT description,code_value FROM global_code_table WHERE code_name = 'ELUX_CONSUMPTION_TYPES'");
    populateListFromQuery('part_usage','user_def16', conSump, true);
}

 

 

Regards,

Pinmaya

 

Hi ​@Pinmaya Kumar Singh 

SQLite is case-sensitive for string comparisons by default. If the code_value can have different capitalisations (e.g., "scrap", "SCRAP", "Scrap"), you might want to use LOWER() to ensure you are comparing it case-insensitively:

For example

...
LOWER(code_value) != 'scrap'
...

Also, change your whole query to lowercase.

SELECT → select; FROM → from; etc.

Make sure to assign the script on the after value change event of custom.from_part_needs field

 

Cheers!


 

@Shneor Cheshin 

 

var IsChecked = getControlValue("custom","from_part_needs");
if (IsChecked == 'N') 
{
   var conSump = stringFormat("select description, code_value FROM global_code_table WHERE code_name = 'ELUX_CONSUMPTION_TYPES' AND code_value != 'scrap'");
   populateListFromQuery('part_usage','user_def16', conSump, false);
}
else
{
    var conSump = stringFormat("select description,code_value FROM global_code_table WHERE code_name = 'ELUX_CONSUMPTION_TYPES'");
    populateListFromQuery('part_usage','user_def16', conSump, true);
    
}

 

 

The script is working but the thing is I am not able to hide the dropdown value scrap when I uncheck the from part need field. Its there in the dropdown while we open, I want it should completely not be seen from drop down when we uncheck the from part need checkbox .

 

 

Thanks,


Hi ​@Pinmaya Kumar Singh 

Looks like you are doing the correct things. A few tips to troubleshoot and achieve the required result.

Assuming your SQL scripts return the correct results.

Did you check that the script is triggered? Is it entering the correct conditions? if/else

An option is adding a NULL/EMPTY assignment to the field before you populate it.

For example (check syntax)

var IsChecked = getControlValue("custom","from_part_needs");

if (IsChecked == 'N')
{
setControlValue('part_usage','user_def16', '');
var conSump = stringFormat("select description, code_value FROM global_code_table WHERE code_name = 'ELUX_CONSUMPTION_TYPES' AND code_value != 'scrap'");
populateListFromQuery('part_usage','user_def16', conSump, false);
}
else
{
setControlValue('part_usage','user_def16', '');
var conSump = stringFormat("select description,code_value FROM global_code_table WHERE code_name = 'ELUX_CONSUMPTION_TYPES'");
populateListFromQuery('part_usage','user_def16', conSump, true);

}

Another option, change your query to use the ‘IN’ clause instead of the not equal sign.

if(...)
select ... and code_value in('VALUE1','VALUE2', ...)
else
select ... and code_value in('VALUE2', ...)

Cheers!


Hi ​@Shneor Cheshin 

Thanks so much, I found out the issue now the other refresh script was running on the screen and conflicting my script though our script was correct.

So need to find another solution.

 

Regards,

Pinmaya


Reply