Populate Choice Values in Dropdown from Record - is it possible?

Hi,

How would I go about getting option 1 and option 2.

show up in my choice labels for a dropdown.

Is this even possible?

All similar topics, didnt result in very good answers.

  Discussion posts and replies are publicly visible

Parents
  • Hi ,

    You can try a code similar to the below one:

    a!localVariables(
      local!a: a!queryRecordType(
        recordType: 'recordType!BTM Cost Center',
        pagingInfo: a!pagingInfo(1,500)
      ).data,
      local!b,
      {
      a!dropdownField(
        value: local!b,
        placeholder: "Please select",
        choiceLabels: index(local!a, 'recordType!BTM Cost Center.fields.CostCenterLabel',null),
        choiceValues:  index(local!a, 'recordType!BTM Cost Center.fields.CostCenterId',null),
      )
    
      }
    )

    This code it is not fully working as I tried to mock up your recordType, so you will need to adjust these bits, but if what your were looking for was to display the CostCenterLabel and store the CostCenterId, the concept is in there.

    Regards,

    Acacio B.

  • Hi ,

    thanks for the help. I noticed I was really just missing the index function so I did the following:

    a!dropdownField(
      label: "Cost Center",
      labelPosition: "ABOVE",
      placeholder: "--- Select a Value ---",
      choiceLabels: index(
        a!queryRecordType(
        recordType: 'recordType!{b106c553-3b20-4906-bfdc-16b9ce3c420d}BTM CostCenter',
        fields: 'recordType!{b106c553-3b20-4906-bfdc-16b9ce3c420d}BTM CostCenter.fields.{8abcfd37-4d60-4002-ad88-ab282d3ed5a1}costcenterlabel',
        pagingInfo: a!pagingInfo(startIndex: 1, batchSize: 500)
      ).data,
        'recordType!{b106c553-3b20-4906-bfdc-16b9ce3c420d}BTM CostCenter.fields.{8abcfd37-4d60-4002-ad88-ab282d3ed5a1}costcenterlabel',
        null()
      )
    ,
      choiceValues: index(
        a!queryRecordType(
        recordType: 'recordType!{b106c553-3b20-4906-bfdc-16b9ce3c420d}BTM CostCenter',
        fields: 'recordType!{b106c553-3b20-4906-bfdc-16b9ce3c420d}BTM CostCenter.fields.{88b6b0f8-52e0-46d0-8613-21d91da4b473}costcenterid',
        pagingInfo: a!pagingInfo(startIndex: 1, batchSize: 500)
      ).data,
        'recordType!{b106c553-3b20-4906-bfdc-16b9ce3c420d}BTM CostCenter.fields.{88b6b0f8-52e0-46d0-8613-21d91da4b473}costcenterid',
        null()
      ),
      value: ri!record.costcenterid,
      saveInto: ri!record.costcenterid,
      searchDisplay: "AUTO",
      validations: {}
    )

Reply
  • Hi ,

    thanks for the help. I noticed I was really just missing the index function so I did the following:

    a!dropdownField(
      label: "Cost Center",
      labelPosition: "ABOVE",
      placeholder: "--- Select a Value ---",
      choiceLabels: index(
        a!queryRecordType(
        recordType: 'recordType!{b106c553-3b20-4906-bfdc-16b9ce3c420d}BTM CostCenter',
        fields: 'recordType!{b106c553-3b20-4906-bfdc-16b9ce3c420d}BTM CostCenter.fields.{8abcfd37-4d60-4002-ad88-ab282d3ed5a1}costcenterlabel',
        pagingInfo: a!pagingInfo(startIndex: 1, batchSize: 500)
      ).data,
        'recordType!{b106c553-3b20-4906-bfdc-16b9ce3c420d}BTM CostCenter.fields.{8abcfd37-4d60-4002-ad88-ab282d3ed5a1}costcenterlabel',
        null()
      )
    ,
      choiceValues: index(
        a!queryRecordType(
        recordType: 'recordType!{b106c553-3b20-4906-bfdc-16b9ce3c420d}BTM CostCenter',
        fields: 'recordType!{b106c553-3b20-4906-bfdc-16b9ce3c420d}BTM CostCenter.fields.{88b6b0f8-52e0-46d0-8613-21d91da4b473}costcenterid',
        pagingInfo: a!pagingInfo(startIndex: 1, batchSize: 500)
      ).data,
        'recordType!{b106c553-3b20-4906-bfdc-16b9ce3c420d}BTM CostCenter.fields.{88b6b0f8-52e0-46d0-8613-21d91da4b473}costcenterid',
        null()
      ),
      value: ri!record.costcenterid,
      saveInto: ri!record.costcenterid,
      searchDisplay: "AUTO",
      validations: {}
    )

Children