Determining the different options of a pull-down menu from a database entity?

Certified Associate Developer

I am trying to populate the values of a pull-down menu from a database. For this purpose, I defined cons!GENERIC_TASKS which points to corresponding database entity. I also have the following expression rule which reads all necessary data from the respective entity:

a!queryEntity(
  entity: cons!GENERIC_TASKS,
  query: a!query(
    selection: a!querySelection(
      columns: {
        a!queryColumn(
          field: "genericTaskName"
        )
      }
    ),
    pagingInfo: a!pagingInfo(
      startIndex: 1,
      batchSize: -1
    )
  ),
  fetchTotalCount: false
)

The test result of this rule looks promising since it contains all required data, the labels and the values.

In my user interface, I am now trying the following:

    a!dropdownField(
      label: "Generic step type",
      labelPosition: "ABOVE",
      placeholder: "--- Please choose a step type ---",
      choiceLabels: {rule!APAS_GetAllGenericTaskNames.data.genericTaskName},
      choiceValues: {rule!APAS_GetAllGenericTaskNames.data.identifiers},
      saveInto: {},
      searchDisplay: "AUTO",
      validations: {}
    )

However, this gives me the following error:

Could not display interface. Please check definition and inputs. Interface Definition: Expression evaluation error at function a!dropdownField: Invalid index: Cannot index property 'data' of type Text into type Rule or Function Reference

What do I do wrong?

  Discussion posts and replies are publicly visible

Parents
  • Hi,

    I think you are missing () while calling the rules.

    choiceLabels: {rule!APAS_GetAllGenericTaskNames().data.genericTaskName},
          choiceValues: {rule!APAS_GetAllGenericTaskNames().data.identifiers},
  • 0
    Certified Associate Developer
    in reply to Arun Dubey

    I still receive an error:

    Could not display interface. Please check definition and inputs. Interface Definition: Expression evaluation error at function a!dropdownField [line 19]: A dropdown component [label=“Generic step type”] has an invalid value for “choiceValues”. Choice values cannot be null.

    This is curious, because I explicitly neither allowed null-values in the column genericTaskName of underlying database table, nor are there any null-values in the table.

    The types seem to fit, at least when testing the expression rule.

  • choiceValues: {rule!APAS_GetAllGenericTaskNames.data.identifiers}
    Why are you using identifiers ?
    I don't know your use case but if you are trying to store or display then use same for both
    choiceLabels and choiceValues.

    choiceLabels: {rule!APAS_GetAllGenericTaskNames().data.genericTaskName},
          choiceValues: {rule!APAS_GetAllGenericTaskNames().data.genericTaskName},
     
Reply
  • choiceValues: {rule!APAS_GetAllGenericTaskNames.data.identifiers}
    Why are you using identifiers ?
    I don't know your use case but if you are trying to store or display then use same for both
    choiceLabels and choiceValues.

    choiceLabels: {rule!APAS_GetAllGenericTaskNames().data.genericTaskName},
          choiceValues: {rule!APAS_GetAllGenericTaskNames().data.genericTaskName},
     
Children
No Data