Using a List Colloctor to set Check Boxes on a form

EricG2
Tera Expert

I have a task for our On-boarding process.

 

What I'd like to do is have a list collector on my Order Guide that will show all available "Product Catalog Items" for available software to be installed.

 

When a user select from the 80 items we have (Lets say 5 are selected on the right side of the LC), then I'd like those check boxes to appear Checked on the order guide..

 

So that when they "Choose Options", those selected forms are there.

Or if there is an easier way then having 80 visible check boxes, I'd love the insights.

 

I think i've seen a similar post, but I can't find it.

3 REPLIES 3

BrianProvencher
Giga Guru

The way we have it set up is using a variable set containing all of the applications. Then the rule base on the order guide includes each application form based on the options selected in the Order Guide.

 

BrianProvencher
Giga Guru

You could create business rules to select those boxes, but that might get over-complicated.

EricG
Kilo Sage

@BrianProvencher could you explain your solution further please.  I'm not following.

 

I tried using Copilot to generate the an onChange client script - but it's not showing the check box or checking it.

EricG_0-1746710516163.png

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

    //Type appropriate comment here, and begin script below
    var selectedValues = g_form.getValue('approved_sft_list'); // comma-separated string
    var selectedArray = selectedValues.split(',');

    // Define mapping between list values and checkbox field names
    var checkboxMap = {
        'c34238ba9315aa10ccf2b91c5cba1067': 'nho_3core',
        'b462743e9315aa10ccf2b91c5cba1003': 'nho_a3',
        '5492f07e9315aa10ccf2b91c5cba1038': 'nho_anaconda',
        'd47ea0729315aa10ccf2b91c5cba1014': 'nho_adobe_creative_cloud',
        'a2a2bc7e9315aa10ccf2b91c5cba1059': 'nho_Arbitrage',
        '11c2fc3e9315aa10ccf2b91c5cba102fn': 'nho_Axacore'
    };

    //confirm("Software fired");
    // Loop through the map and set checkboxes

    for (var key in checkboxMap) {
        if (checkboxMap.hasOwnProperty(key)) {
            var checkboxField = checkboxMap[key];
            var shouldCheck = selectedArray.includes(key);

            // Show the checkbox field
            g_form.setDisplay(checkboxField, true);

            // Set the checkbox value to true or false
            g_form.setValue(checkboxField, shouldCheck ? 'true' : 'false');// 
        }
    }
}