Reputation: 53
I am working on setting up a dynamic value for a dropdown. Currently, I am using a static JSON to populate it, but I plan to replace the static JSON with a dynamic script. However, I am facing an issue where I am unable to set the JSON values into the dropdown using this script.
When i am setting static dropdown it's working. The issue is with dynamic value only. i am just getting 1 as list value
type: update
name: Test Add-On
id: test-schedule
logo: /images/schedule-logo.png
description: Test Add-On for schedule functionality.
targetNodes:
nodeGroup:
- bl
- cp
globals:
bckDates: []
onInstall:
- getbckDates
actions:
getbckDates:
- script: |
var dates = [];
dates = [
{
value: "",
caption: "Select date"
},
{
value: "2024-10-01",
caption: "2024-10-01"
},
{
value: "2024-10-02",
caption: "2024-10-02"
}
];
return {
result: 0,
bckDates: dates
};
- setGlobals:
bckDates: ${response.bckDates}
settings:
schedule:
fields:
- type: list
name: bckDates
caption: Select schedule Date
required: true
width: 300
values:
- value: ""
caption: "Loading schedule dates..."
- script: |
var resp = api.getResponse();
if (resp && resp.bckDates && Array.isArray(resp.bckDates)) {
return resp.bckDates;
}
return [
{value: "", caption: "Select schedule date"},
{value: "error", caption: "Failed to load schedule dates"}
];
buttons:
- caption: DateList
action: schedule
loadingText: scheduling process...
settings: schedule
successText: successfully setup done.
title: Schedule Done
submitButtonText: Start Schedule
Upvotes: 0
Views: 21