Disabled in dropdown

Certified Associate Developer

Hi all, 

I have a dropdown field and have a condition for disbaled, based on that it will be disabled or not.
--> if it's not null or empty it's working fine

--> if it's null or empty, the dropdown is not disabled and I'm able to select a value for first time. Once I select the value, the dropdown gets disabled. ( since it considers that the field is not null and it's disabled. But I want the field to be editable) Can someone please help here.  

disabled: {
if(
a!isnullormepty(ri!record[my dropdown field])
false,
true
),

},

  Discussion posts and replies are publicly visible

Parents Reply Children
  • 0
    Certified Associate Developer
    in reply to Mike Schmitt

    In my case, when I pull the data from the external system the field is blank. So the user can select the value from the dropdown. But once after I select a value from a dropdown, it's getting disabled ( I think it's because it checks the condition isnotnullorempty and it's getting disabled). But I want to remain it as a editable field ( since the data from the external system is blank) 

  • 0
    Certified Lead Developer
    in reply to hema.mathivathanan
    But I want to remain it as a editable field

    So if you remove / comment the "disabled" parameter, it will remain editable.  What is your intention behind disabling it conditionally?

    a!dropdownField(
      label: "dropdown",
      choiceLabels: {},
      choiceValues: {},
      value: ri!record[fieldname],
      saveInto: ri!record[fieldname],
      disabled: false(),   /* this can either be "false()" or just removed if you never need it to be disabled */
      required: true()
    )

  • 0
    Certified Lead Developer
    in reply to hema.mathivathanan

    You cannot combine that logic into one value. Let's dissect that.

    You have a dropdown. In case you get a value from the external system, this value shall be disabled. Correct? So, you will have to check the data as it comes in and, in a separate local variable, define whether to disable that field. Then use that for the disabled parameter.

    Then you can use the actual record field just for the purpose it is meant for. Store the selected value.

  • 0
    Certified Associate Developer
    in reply to Stefan Helzle

    yeah, exactly this is my requirement. So when I store in the local variable should I store the field name alone?

  • 0
    Certified Lead Developer
    in reply to hema.mathivathanan

    Can you clarify exaclty what information you're getting from the external system, how, and when?  Stefan seems to have figured out something here but I'm still a little fuzzy with respect to what the desired sequence of events is, and the shape of the data. 

    What are you storing at first, and why?

    When you say "when I store in the local variable", what information are you referring to being stored there?

  • 0
    Certified Associate Developer
    in reply to Mike Schmitt

    I am getting a value from the external system. I need the initial value to get stored. Based on which, I need to disable. Hope I answered your question

  • 0
    Certified Lead Developer
    in reply to hema.mathivathanan
    I need the initial value to get stored. Based on which, I need to disable.

    Sorry, that's still super unclear.  Can you write out, in a list of steps, what you are hoping the user's experience will be?  When is "value from the external system" being loaded, and how (i asked this before)?  What are you expecting "the initial value" to be, and what do you mean exactly by "get stored"?

    for example, i'm hoping to see something looking like:

    1. the user loads the task, at first the Dropdown appears but has no selections and is DISABLED
    2. the user presses a button labelled "load external data" which sends an API call and gets back a list of results
    3. the API call results are stored into local!myApiCallResults
    4. the local!myApiCallResults will become selectable in the Dropdown Field
    5. the user is able to make a selection from the results, and that value is stored into ri!myRecordType[dropdownSelection]
    6. the dropdown should remain ENABLED, and the user can continue changing their selections, prior to SUBMIT being pressed.

    The above is a sequence I invented, and I intend it to be vaguely similar to your use case (per what I can discern from my point of view and details given so far), but with an assumption that I've gotten certain details wrong / backwards / etc.

    This is the amount of detail we need from you here in order to tell precisely what the User Experience is intended to be, with further details specifying exactly how and why the current experience is not matching what you had hoped for.

  • 0
    Certified Associate Developer
    in reply to Mike Schmitt

    This is fixed. This is what I did. 

    I had a expression rule which returns the record by its ID. I used a local variable which uses this expression rule. ( so this stores the initial value from the DB) In the dropdown field, I configured "disabled" based on the value from the local variable.