This commit is contained in:
Mehul945 2026-05-12 15:33:01 +03:00 committed by GitHub
commit b38b759a63
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -92,18 +92,19 @@ export class ERPNext implements INodeType {
},
async getDocFields(this: ILoadOptionsFunctions): Promise<INodePropertyOptions[]> {
const docType = this.getCurrentNodeParameter('docType') as string;
const { data } = await erpNextApiRequest.call(
const response = await erpNextApiRequest.call(
this,
'GET',
`/api/resource/DocType/${docType}`,
`/api/method/frappe.desk.form.load.getdoctype?doctype=${docType}`,
{},
);
const docFields = data.fields.map(
({ label, fieldname }: { label: string; fieldname: string }) => {
return { name: label, value: fieldname };
},
);
const docFields = response.docs
.flatMap((doc: { fields: { label: string; fieldname: string }[] }) => doc.fields)
.map(({ label, fieldname }: { label: string; fieldname: string }) => ({
name: label,
value: fieldname,
}));
return processNames(docFields);
},