chore: fix Select dropdown options loading from Settings

This commit is contained in:
root 2026-07-16 14:43:30 +00:00
parent 7243188e97
commit e84b04ddd8
2 changed files with 19 additions and 32 deletions

View file

@ -1,6 +1,6 @@
# Service Factory — ERPNext Custom App Project
> **Current Version: V0.1.0017** — Each completed prompt/step increments the patch number by 1 (V0.1.0000 → V0.1.0001 → V0.1.0002…). The agent automatically commits and pushes after every step.
> **Current Version: V0.1.0018** — Each completed prompt/step increments the patch number by 1 (V0.1.0000 → V0.1.0001 → V0.1.0002…). The agent automatically commits and pushes after every step.
## Project Overview

View file

@ -3,9 +3,7 @@
frappe.ui.form.on("Engagement Card", {
refresh: function (frm) {
// Load dynamic options from Settings
load_options(frm);
load_select_options(frm);
// Quick status actions
if (frm.doc.status === "Discovery") {
frm.add_custom_button(__("Move to Delivery"), function () {
@ -66,41 +64,30 @@ frappe.ui.form.on("Engagement Card", {
},
});
function load_options(frm) {
// Fetch task options from Settings
function load_select_options(frm) {
frappe.call({
method: "frappe.client.get_single_value",
method: "frappe.client.get",
args: {
doctype: "Service Factory Settings",
name: "Service Factory Settings",
},
callback: function (r) {
if (!r.message) return;
let doc = r.message;
// Get task types - need full doc for table fields
frappe.call({
method: "frappe.client.get",
args: {
doctype: "Service Factory Settings",
name: "Service Factory Settings",
},
callback: function (resp) {
let doc = resp.message;
if (doc.task_types) {
let task_options = doc.task_types
.map((t) => t.task_type_name)
.join("\n");
frm.set_df_property("task", "options", "\n" + task_options);
frm.refresh_field("task");
}
if (doc.teams) {
let team_options = doc.teams
.map((t) => t.team_name)
.join("\n");
frm.set_df_property("team", "options", "\n" + team_options);
frm.refresh_field("team");
}
},
});
// Set task options
if (doc.task_types && doc.task_types.length) {
let opts = "\n" + doc.task_types.map((t) => t.task_type_name).join("\n");
frm.set_df_property("task", "options", opts);
frm.refresh_field("task");
}
// Set team options
if (doc.teams && doc.teams.length) {
let opts = "\n" + doc.teams.map((t) => t.team_name).join("\n");
frm.set_df_property("team", "options", opts);
frm.refresh_field("team");
}
},
});
}