Custom recipe: Default value not work for values from API

pobutp
pobutp Registered Posts: 2

In plugin I cannot see default value for field in recipe.json, when value comes from API.

In recipe.json I have field:

{
"name": "field",
"label": "Field",
"type": "SELECT",
"getChoicesFromPython": true,
"mandatory": true,
"defaultValue": "Default",
},

In above code default value is set to "Default", but it is not set in the UI. When values are loaded from API the value "Default" is possible to select.

When I change API response with hardcoded values, default value is working fine.
return { "choices": [{"value":"Default", "label": "Default"}, {"value": "Value2", "label": "Value2" }]}

Please help me fix it.

Answers

  • Alexandru
    Alexandru Dataiker, Dataiku DSS Core Designer, Dataiku DSS ML Practitioner, Dataiku DSS Adv Designer, Registered Posts: 1,373 Dataiker

    Hi,
    defaultValue is ignored in this case as getChoicesFromPython take precedent.

    If you want to return a default value, you need to handle it in the getChoicesFromPython code itself. Does this approach work for you?

    Thanks

Setup Info
    Tags
      Help me…