Symptom
- Dropdown IDs and descriptions become misaligned when using the getResultSet API.
- Duplicate IDs are returned by the API, causing incorrect mapping between dropdown selections and their corresponding IDs.
- Current behavior: selecting the second instance of an ID in the dropdown returns an incorrect ID.
- Expected behavior: dropdown values should be unique, and selecting an ID should return the correct corresponding value.
Environment
SAP Analytics Cloud
Reproducing the Issue
- Open the story linked to the dropdown functionality.
- Observe that the dropdown lists contain duplicate values for IDs, such as A.
- Select the second instance of A from the dropdown list.
- Note that the selected ID is returned as B instead of A.
- Expectation: dropdown values should be unique, and selecting a should return A.
Cause
Duplicate values in the result set returned by the API cause misalignment between dropdown IDs and descriptions.
Resolution
- Perform a deduplication operation before assigning the return result of getResultSet to a script variable. Since the dropdown needs unique IDs, having duplicate IDs and texts may cause misalignment.
- Use the following sample code to remove duplicate IDs and descriptions:
```
var originalIds = ["0001", "0002", "0002", "0005", "0005"];
var originalTexts = ["Description1", "0002- Text1", "0002- Text1", "0005- Text2", "0005- Text2"];
var ids = [];
var texts = [];
for (var i = 0; i < originalIds.length; i++) {
if (!ids.includes(originalIds[i])) {
ids.push(originalIds[i]);
}
}
for (var j = 0; j < originalTexts.length; j++) {
if (!texts.includes(originalTexts[j])) {
texts.push(originalTexts[j]);
}
}
```
Keywords
dropdown misalignment, duplicate IDs, result set API, analytics designer framework, dropdown deduplication, misaligned descriptions, dropdown selection issue, API duplicate values, dropdown binding issue, dropdown functionality error , KBA , LOD-ANA-AD-FRA , Analytics Designer Framework , LOD-ANA-UNS-SCR , Unified Story Scripting related Issues , Known Error
SAP Knowledge Base Article - Public