Feature Coverage: Clearing the values of a Catalog slushbucket via scripting

This small piece of script may come in handy if you are working with List Collector Variables in the Catalog.

Let us take the out-of-the-box “Schedule a Move” Record Producer as an example. When the value of the field “Move on behalf of this user” is modified, it would make sense that automatically the Configuration Items that have been selected in the List Collector “Which Equipment do you want to move?” are being cleared: 

Items_selected_for_Joe

 

This would make sure that some Equipments belonging to Joe Employee are not selected if the user to move is modified to “Bob Employee” just before the form is submitted.

Unfortunately, the Client Script’s instructions g_form.clearValue(“<my_slushbucket_variable>”) or g_form.setValue(“<my_slushbucket_variable>”, “”) do not work for slushbuckets. 🙁

But at Fruition Partners we love to find simple and convenient workaround when we face this kind of small limitations in the system! Therefore, by creating a short “onChange” Client Script on the “Move on behalf of this user” Variable, we can do exactly what we want:

/**

 * When the User changes, clears the values already selected

 * in the List Collector.

 */

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

    try {

        if(isLoading == false) {
            // Gets the right column of the List Collector
            var rightSlushbucket = gel(“items_to_move__select_1”);

            // Loops through all the selected entries and remove them
            while(rightSlushbucket.firstChild) {

                if(rightSlushbucket.firstChild != null && rightSlushbucket.firstChild != “”) {

                    rightSlushbucket.removeChild(rightSlushbucket.firstChild);

                }

            }

        }

    } catch(exception) {

        jslog(‘Error in Catalog Client Script “Clear Slushbucket values”: ‘ + exception);

    }

}

 

And one more time, scripting and modification of the DOM saves the day!

    Recommended Posts

    Leave a Comment

    Start typing and press Enter to search