Show count of values selected in List collector.

Kush Sharma
Tera Guru

Guys , I have one list collector variable named 'user' which is referred to sys_user table . Now requirement is to show count of users selected in one variable named 'count' which is a simple text field.. Please help

1 ACCEPTED SOLUTION

Yes you can.

Try below as an onChange() client script that runs when list collector field has values added.

function onChange(control, oldValue, newValue, isLoading) {
    if (isLoading || newValue == '') {
        return;
    }

    var checkcount = g_form.getValue('listcollectorvriablename');
    var len = checkcount.split(',').length;
    alert('Length is ' + len);
    g_form.setValue('yourcountfield', len);

}

 

View solution in original post

4 REPLIES 4

Ashutosh Munot1
Kilo Patron
Kilo Patron

Hi,

You can write a code as below in BR if it has to happen in background.

var listC = current.fieldnameoflistcollector;

var spl = listC.split(',');

current.countfieldname = spl.length;


Thanks,
Ashutosh

Thanks Ashutosh . is there any way to do it via client script ?

Yes you can.

Try below as an onChange() client script that runs when list collector field has values added.

function onChange(control, oldValue, newValue, isLoading) {
    if (isLoading || newValue == '') {
        return;
    }

    var checkcount = g_form.getValue('listcollectorvriablename');
    var len = checkcount.split(',').length;
    alert('Length is ' + len);
    g_form.setValue('yourcountfield', len);

}

 

Community Alums
Not applicable

Hi, 

 

The solution you proposed is working perfectly.

But one query, the value is coming up in the decimal. how can we change that.

Any suggestions please.

 

Regards, 

Vinod.