mirror of
https://github.com/n8n-io/n8n.git
synced 2025-03-05 20:50:17 -08:00
populate workflow Inputs
This commit is contained in:
parent
0a924e0dd3
commit
0ffc72a8a3
|
@ -199,7 +199,7 @@ export class ExecuteWorkflow implements INodeType {
|
|||
},
|
||||
required: true,
|
||||
typeOptions: {
|
||||
loadOptionsDependsOn: ['workflowId.value'],
|
||||
loadOptionsDependsOn: ['workflowId.value', 'workflowJson'],
|
||||
resourceMapper: {
|
||||
resourceMapperMethod: 'getWorkflowInputs',
|
||||
mode: 'add',
|
||||
|
@ -214,11 +214,11 @@ export class ExecuteWorkflow implements INodeType {
|
|||
},
|
||||
displayOptions: {
|
||||
show: {
|
||||
source: ['database'],
|
||||
'@version': [{ _cnd: { gte: 1.2 } }],
|
||||
},
|
||||
hide: {
|
||||
workflowId: [''],
|
||||
workflowJson: ['\n\n\n'],
|
||||
},
|
||||
},
|
||||
},
|
||||
|
|
|
@ -1,22 +1,42 @@
|
|||
import type {
|
||||
FieldType,
|
||||
ILoadOptionsFunctions,
|
||||
ResourceMapperField,
|
||||
ResourceMapperFields,
|
||||
} from 'n8n-workflow';
|
||||
|
||||
import { getWorkflowInfo } from '../GenericFunctions';
|
||||
|
||||
export async function getWorkflowInputs(
|
||||
this: ILoadOptionsFunctions,
|
||||
): Promise<ResourceMapperFields> {
|
||||
// TODO: take the columns from the workflow input
|
||||
const workflowInputs = ['uid', 'Test Field 2', 'Test Field 3'];
|
||||
const source = this.getNodeParameter('source', 0) as string;
|
||||
|
||||
const fields: ResourceMapperField[] = workflowInputs.map((col) => ({
|
||||
id: col,
|
||||
displayName: col,
|
||||
const executeWorkflowInfo = await getWorkflowInfo.call(this, source);
|
||||
|
||||
if (executeWorkflowInfo.code === undefined) {
|
||||
// executeWorkflowInfo.code = await getWorkflowById.call(this, executeWorkflowInfo.id as string);
|
||||
}
|
||||
|
||||
const workflowInputs = (
|
||||
Array.isArray(
|
||||
executeWorkflowInfo.code?.nodes.find(
|
||||
(node) => node.type === 'n8n-nodes-base.executeWorkflowTrigger',
|
||||
)?.parameters.workflowInputs,
|
||||
)
|
||||
? executeWorkflowInfo.code?.nodes.find(
|
||||
(node) => node.type === 'n8n-nodes-base.executeWorkflowTrigger',
|
||||
)?.parameters.workflowInputs
|
||||
: []
|
||||
) as Array<{ name: string; type: FieldType }>;
|
||||
|
||||
const fields: ResourceMapperField[] = workflowInputs.map((currentWorkflowInput) => ({
|
||||
id: currentWorkflowInput.name,
|
||||
displayName: currentWorkflowInput.name,
|
||||
required: false,
|
||||
defaultMatch: true,
|
||||
display: true,
|
||||
type: 'number',
|
||||
type: currentWorkflowInput.type || 'string',
|
||||
canBeUsedToMatch: true,
|
||||
}));
|
||||
|
||||
|
|
Loading…
Reference in a new issue