Selecting on custom single value drop down attributes on in SDK app returns an unexpected result
search cancel

Selecting on custom single value drop down attributes on in SDK app returns an unexpected result

book

Article ID: 254384

calendar_today

Updated On:

Products

Rally On-Premise Rally SaaS

Issue/Introduction

Since October 11, selecting a value from a custom single value dropdown list (xtype: rallyfieldvaluecombobox) in an SDK app may return unexpected results or an error, depending on the logic that is consuming the field value.  

Environment

SDK Apps

Cause

An update was made to fix a defect in the API which resulted in the correct ObjectID being returned in the Attribute value for AllowedAttributeValues on a constrained custom field.  This resulted in the valueField of custom dropdown lists being populated with the reference instead of the name.  

Resolution

For the short term, a toggle was enabled to revert the fix for customers who this caused an issue for.  In the longer term the toggle will be removed when customers have the chance to mitigate the issue.  

 

The issue can be addressed in the App SDK code in the configuration for a rallyfieldvaluecombobox by adding an explicit valueField configuration:

valueField: 'name'

Here is an example of the entire configuration:  

this.add({
                xtype: 'rallyfieldvaluecombobox',
                model: 'HierarchicalRequirement',
                field: 'myCustomFieldName',
                fieldLabel: 'my Custom Field',
                valueField: 'name',  /*** Add this configuration to always return the name ***/ 
                listeners: {
                    select: function(cb){  console.log('value: ', cb.getValue()); }
                }
            });

 

Additional Information

Below is an example app that demonstrates the difference in configuration and how it affects the returned values (if the fix is enabled in your subscription):  

<!DOCTYPE html>
<html>
<head>
    <title>Dropdown Attribute Object ID Test</title>

    <script type="text/javascript" src="/apps/2.1/sdk.js"></script>


    <script type="text/javascript">
        Rally.onReady(function() {
             

Ext.define("Rally.app.DropdownAttributeObjectIDExample", {
    extend: 'Rally.app.App',
    componentCls: 'app',
    defaults: { margin: 10 },

    launch: function() {
        this.add({
            xtype: 'rallyfieldcombobox',
            model: 'HierarchicalRequirement',
            fieldLabel: 'Choose a Custom Dropdown Field',
            labelWidth: 300,
            labelAlign: 'right',
            listeners: {
                select: this.updateFieldValueComboBoxes,
                scope: this,
                ready: this.updateFieldValueComboBoxes,
            },
            _isNotHidden: function(field) {
                if (field && field.custom && field.attributeDefinition && field.attributeDefinition.AttributeType === 'STRING' && field.attributeDefinition.Constrained){
                    return !field.hidden;
                }
                return false;
            },
        });

        this.add({
            xtype: 'container',
            itemId: 'fieldValueComboContainer'
        });

    },
    updateFieldValueComboBoxes: function(cb, records){
        console.log('updateFieldValueComboBoxes',cb,records);
        customField = cb.getValue();
        this.down('#fieldValueComboContainer').removeAll();
        this.down('#fieldValueComboContainer').add({
            xtype: 'container',
            layout:'hbox',
            items: [{
                xtype: 'rallyfieldvaluecombobox',
                model: 'HierarchicalRequirement',
                field: customField,
                itemId: 'comboNotFixed',
                fieldLabel: 'Select a Value (original configuration)',
                labelAlign: 'right',
                labelWidth: 300,
                labelAlign: 'right',
                listeners: {
                    select: function(cb, records){
                        this.down('#valueNotFixed').setValue(cb.getValue());
                    },
                    scope: this
                }
            },{
                xtype: 'rallytextfield',
                itemId: 'valueNotFixed',
                border: false,
                width: 400,
                height: 22,
                labelWidth: 100,
                labelAlign: 'right',
                fieldLabel: 'Returned Value'
            }]
        });
        this.down('#fieldValueComboContainer').add({
            xtype: 'container',
            layout:'hbox',
            items: [{
                xtype: 'rallyfieldvaluecombobox',
                model: 'HierarchicalRequirement',
                field: customField,
                itemId: 'comboFixed',
                fieldLabel: 'Select a Value (fixed configuration)',
                labelAlign: 'right',
                labelWidth: 300,
                valueField: 'name',  /*** Add this configuration to fix the issue ***/
                listeners: {
                    select: function(cb){
                        this.down('#valueFixed').setValue(cb.getValue());
                    },
                    scope: this 
                }
            },{
                xtype: 'rallytextfield',
                itemId: 'valueFixed',
                border: false,
                width: 400,
                height: 22,
                labelWidth: 100,
                labelAlign: 'right',
                fieldLabel: 'Returned Value'
            }]
        });
    }

});


               Rally.launchApp('Rally.app.DropdownAttributeObjectIDExample', {
                   name: 'Dropdown Attribute Object ID'
               });
        });
    </script>

    <style type="text/css">

.app {
}
    </style>

</head>
<body></body>
</html>