Community Spring Cleaning week is here! Join your fellow Maveryx in digging through your old posts and marking comments on them as solved. Learn more here!

Dev Space

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

Custom tool configuration not updating from GUI selection changes

rpaugh
11 - 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));
});
1 REPLY 1
rpaugh
11 - 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));
          }
        );