Skip to main content
Question

Problema ao Salvar informações ao utilizar populateListFromQuery

  • December 16, 2025
  • 2 replies
  • 11 views

prazz
Do Gooder (Employee)
Forum|alt.badge.img+1
  • Do Gooder (Employee)

Hello everyone,

I have the following problem in FSM Mobile: when using the function populateListFromQuery, the list is filtered as expected, but when saving the information, the field does not save the selected value. I imagine that when performing the filtering, it must be somehow setting it as empty.

 

Is there a solution for this?

Script:

var taskId = getCurrentKeys("task", "task_id");
setCurrentKeys("task", "task_id", taskId);

var tensao = getDBValue(stringFormat("select com_voltage from task where task_id ='{0}'",taskId));

if (tensao >= 4 || tensao <= 9){
    var query = "select code_value, description from global_code_table where code_name = 'C_CELESC_LACRE_LOCALIZACAO' and user_def1 ='A'";
    populateListFromQuery("c_task_lacres","c_localizacao_do_lacre",query,true);
} else if (tensao >= 1 || tensao <= 3){
    var query = "select code_value, description from global_code_table where code_name = 'C_CELESC_LACRE_LOCALIZACAO' and user_def1 ='B'";
    populateListFromQuery("c_task_lacres","c_localizacao_do_lacre",query,true);
}


 

2 replies

Shneor Cheshin
Superhero (Employee)
Forum|alt.badge.img+28
  • Superhero (Employee)
  • December 16, 2025

Hi ​@prazz 

Some details are missing.

  1. Which screen is it?
  2. When does the attached script run?
  3. Do you have an override/validation script for the save event?
  4. If you simply hard-code a value with ‘setControlValue(...), does it work?

Cheers!


prazz
Do Gooder (Employee)
Forum|alt.badge.img+1
  • Author
  • Do Gooder (Employee)
  • December 18, 2025

Hi ​@Shneor Cheshin 

I managed to solve the issue by adding a check for null values; if the value is null, the populateListFromQuery function is not executed. It seems that when populateListFromQuery is triggered, its behavior is to filter the list and 'clear' the current value.


var locLacre = getControlValue("c_task_lacres","c_localizacao_do_lacre");


if (isNullOrEmptyString(locLacre) == true){
    //grupo A
    if (tensao >= 4 || tensao <= 9){
        var query = "select description, code_value from global_code_table where code_name = 'C_CELESC_LACRE_LOCALIZACAO' and user_def1 ='A'";
        populateListFromQuery("c_task_lacres","c_localizacao_do_lacre",query,true);
        
    //grupo B
    } else if (tensao >= 1 || tensao <= 3){
        var query = "select description, code_value from global_code_table where code_name = 'C_CELESC_LACRE_LOCALIZACAO' and user_def1 ='B'";
        populateListFromQuery("c_task_lacres","c_localizacao_do_lacre",query,true);
    }
}

 

Thx