community
cancel
Showing results for 
Search instead for 
Did you mean: 

Dev Space

Customize & extend the power of Alteryx. SDKs, APIs, custom tools, and more!
SOLVED

Custom tool configuration not updating from GUI selection changes

Bolide

I'm running into an issue where using one control (drop-down list) to update a set of values in another control (list box) does not update the tool's configuration with the new values when clicking out of the tool and/or running it.  The values in the list box are the fields that will be added to metadata and sent to the output stream.

 

Consider the following drop-down values and their associated list box values:

 

Drop Down ValuesList Box Values
Option 1

Id

 Name
 Date
  
Option 2Id
 Name

 

When I select Option 1 and check all of the values, the tool outputs fields Id, Name, and Date in the stream.  However, when I switch the drop-down to Option 2 and ensure that Id and Name are selected, the tool fails because it's still sending "Date" to the output stream even though it's no longer available and is not a valid value for the Option 2 selection.  When I switch the drop-down back to Option 1, all three fields show up again and sure enough, Date is still selected.  If I uncheck it here and switch back to Option 2 then the proper fields are selected and the tool runs fine.

 

It looks like Alteryx is retaining all field selections from the list box in the configuration, even when the available fields change.  How do I force the tool to wipe out any existing field selections and replace with the new ones when you click out of the tool on the canvas or run the workflow.

 

Here's what I'm doing in the Alteryx.Gui.AfterLoad section to refresh the list box when the drop-down selection changes:

 
manager.getDataItem('DropDown').registerPropertyListener('value', function (e) {
     manager.getDataItem('Fields').setOptionList(getFields(e.value));
});
Bolide

Updating the code to the following fixed the issue (bolded line added):

 

 

manager.getDataItem('DropDown').registerPropertyListener('value', 
          function (e) { 
            manager.getDataItem('Fields').setValue([]);
            manager.getDataItem('Fields').setOptionList(getFields(e.value));
          }
        );