The CreatorCon Call for Content is officially open! Get started here.

Filtering data with look up select box and getting the last value into a text box, and repeat the process without losing the first value captured

jorgetop
Kilo Contributor

Hi there,

I ´m using look up select boxes variables to filter information from tables, so users just have access to the data that corresponds depending of the options   in each look up select box, this works good, and the last value we need to get it and set it in a multiple line text, so filters just work to find these data, but we need that   user can do this process several times, so we need to keep the first value set in the multiple line text and capture the second and etc.

The first time is simple to get the value and set it with an onChange catalog client script:

function onChange(control, oldValue, newValue, isLoading) {

    if (isLoading || newValue == '') {

          return;

    }

  CDs_selected = g_form.getValue('CD_add_by_site');

  g_form.setValue('CD_selected',CDs_selected);

}

The problem is that the 2nd time the first value is replace by the new value, probably need to convert the value to string and use \n to print each value in a new line, and storing the values with the "+=" operator.

Appreciate any help on this!!

Thanks

3 REPLIES 3

ccajohnson
Kilo Sage

Since you want to concatenate the cd_selected variable and add the cd_add_by_site to it, we may need to grab the multi-line text field first in order to add to it:



function onChange(control, oldValue, newValue, isLoading) {


      if (isLoading || newValue == '') {


              return;


      }


      var mLineTxt = g_form.getValue('cd_selected');


      mLineTxt += g_form.getValue('cd_add_by_site') + '\n';


      g_form.setValue('CD_selected', mLineTxt);


}


Hi Christopher,


Thanks for the quick response, I was trying to adapt the script but couln't make it work, so I'll share with you some details that I missed in my question:



- The variable which store the value can be any of twelve options, there is no specific order that they can be selected by user


- Not sure if an Onchange script is the solution due to there are 12 variables options where the value to capture is displayed


- Each time that user filter and select the option to store, the value has to be capture in the multiline text box



e.g.


Those are lookup select box   variables       // This filters can be used several times in the form



Select side


select building


select project



select Customer Dimensions     // This is the value to be store in the next field but there are 12 diferent variables due to they show diferent labels and comes from diferent filters route because some sites doesn`t have projects, or they have divisions instead of buldings, etc.



Selected Customer Dimensions // Multiple select box



CD 1


CD2


......



Hope this helps to make it clear for you


Thanks, appreciate your help


Best regards


Is the Customer Dimensions the Lookup Select box? If it is, it sounds like it is filtered to only show those selections that are applicable above. Since Lookup Select boxes use reference qualifiers to filter, you may be able to use a List Collector type variable. This may solve the need to select only certain values and not others. You may want to experiment with using a List Collector to show the values that the Lookup Select box has and see if that is more desirable.