Page 1 of 1

Create a multi select variable from a roster column

Posted: September 30th, 2023, 9:28 am
by blumski
Hello Users,

I need your help!

I have a column in a roster which contains names. From that, I want to create a multi select variable containing those names.

The attached file contains a sample app.

Thanks in advance

Re: Create a multi select variable from a roster column

Posted: October 1st, 2023, 8:54 am
by htuser
Hello,
I solved this here: viewtopic.php?p=16688
If you're using CSDB/CSDBE, you can use SQL to built an array with data you want to display, for example Occ number and person names.
However, to extract a list of selected index, I some situations (if numeric you want to extract >10), you'll have to use this function:
Function string extractNumeric (string alphaNumeric) {Specifically to the output of dynamic checkboxes AKA CSPro select dialog}
string result,allNumeric;
if pos('{"rowIndices":[',alphaNumeric) then
           
result=strip(alphanumeric[length('{"rowIndices":[')]);
            allNumeric=result[2:length(result) - 3];
        endif;
        //errmsg ("Le(s) numero(2) de grappe(s) sont (est) %s",allNumeric);
exit allNumeric;
end;
and not the bellow that I used in the codes posted.
  Function string extractNumericFromString (string alphaNumeric) {Can be used only to extract numeric from an alphanumeric string for items to be selected <10}
numeric i;
string isNumeric,allNumeric,result;
do i = 1 while i <= length (strip(alphanumeric))

    if alphanumeric[i:1] in "0":"9" then
 
       
isNumeric=alphanumeric [i:1];
   
        allNumeric = maketext("%s,%s", allNumeric, isNumeric);
    endif;
       
enddo;
result = allNumeric[2:length(allNumeric)];

exit result;
end;
Best,

Re: Create a multi select variable from a roster column

Posted: October 1st, 2023, 10:05 am
by blumski
Thanks alot for your answer, but I'm a bit confused. Where am I gonna use this function (extractNumeric) ?

I you have little time, would you please implement it into my attached app ?

Thanks in advance

Re: Create a multi select variable from a roster column

Posted: October 1st, 2023, 4:55 pm
by htuser
Have you downloaded and played with this download/file.php?id=2334?

Re: Create a multi select variable from a roster column

Posted: October 2nd, 2023, 1:43 am
by blumski
Yes but it seems that it's not the same case with my problem. My sorry it does not help. Have you tried to open my attached app ?

Re: Create a multi select variable from a roster column

Posted: October 2nd, 2023, 6:28 am
by htuser
Here's a working example. And I'm almost using the same code that I previously shared with you.

However, because CSPro 8.0 select dialog have different output compare to 7.7, I had to modify the function extractNumericSelect accordingly.
Please play with the
multi-select-from-roster-column_gv.zip
Dynamic Checkbox,
(66.6 KiB) Downloaded 370 times
using the CSPro 8.0 beta
and let me know if you find any issues.
Best,

Re: Create a multi select variable from a roster column

Posted: October 2nd, 2023, 12:37 pm
by blumski
Thanks alot htuser for reply. I'll try it and give you feedback