Skip to main content

I am having issues trying to understand how to update values using client scripts. My plan is to update non_part_usage.user_def4 to blank if the personID is null or empty.

My understanding is that setControlValue is used to update, but I am not sure how to link the value from the array (npu_id) and setControlValue.

Client Script

var personID = getControlValue('task','person_id');
alert(personID);

if(isNullOrEmptyString(personID))
{
var task_id = getControlValue('task','task_id');
var npu_id = getDBValues('SP_COUNT_NPU',[task_id]);

for(var i=0;i<size(npu_id);++i)
{
setControlValue('non_part_usage', 'user_def4', '');
}
}

Client Script SQL 

SELECT npu_id FROM NON_PART_USAGE WHERE task_id =  '{0}'

A couple of questions:

  1. How do you update the user_def4 to blank?
  2. Is there a way to mass update all the values in the array?

Hi @qquac 

You are working on a related table and not directly on the task.

It would help if you worked with ‘row’ functions.

For example

 

var rows = getDataTableRows('non_part_usage');
if(size(rows) > 0)
{
    for(var i=0;i<size(rows);++i)
    {
var row = rowsri];
        setRowControlValue(row, 'non_part_usage', 'user_def4','');
    }
}

 

Cheers!


Reply